DateValidType-level representation of DateValid.
export interface DateValid extends Date {
readonly "Rebuild": DateValid
}
/**
* Schema for **valid** JavaScript `Date` objects.
*
* **Details**
*
* This schema accepts `Date` instances but rejects invalid dates (such as `new
* Date("invalid")`).
*
* @category Date
* @since 4.0.0
*/
export const const DateValid: DateValidconst DateValid: {
Rebuild: DateValid;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<globalThis.Date, readonly []>) => DateValid;
annotateKey: (annotations: Annotations.Key<globalThis.Date>) => DateValid;
check: (checks_0: SchemaAST.Check<globalThis.Date>, ...checks: Array<SchemaAST.Check<globalThis.Date>>) => DateValid;
rebuild: (ast: SchemaAST.Declaration) => DateValid;
make: (input: globalThis.Date, options?: MakeOptions) => globalThis.Date;
makeOption: (input: globalThis.Date, options?: MakeOptions) => Option_.Option<globalThis.Date>;
makeEffect: (input: globalThis.Date, options?: MakeOptions) => Effect.Effect<globalThis.Date, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
DateValid
.
Schema for valid JavaScript Date objects.
Details
This schema accepts Date instances but rejects invalid dates (such as new
Date("invalid")).
DateValid: DateValid = const Date: Dateconst Date: {
Rebuild: Date;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<globalThis.Date, readonly []>) => Date;
annotateKey: (annotations: Annotations.Key<globalThis.Date>) => Date;
check: (checks_0: SchemaAST.Check<globalThis.Date>, ...checks: Array<SchemaAST.Check<globalThis.Date>>) => Date;
rebuild: (ast: SchemaAST.Declaration) => Date;
make: (input: globalThis.Date, options?: MakeOptions) => globalThis.Date;
makeOption: (input: globalThis.Date, options?: MakeOptions) => Option_.Option<globalThis.Date>;
makeEffect: (input: globalThis.Date, options?: MakeOptions) => Effect.Effect<globalThis.Date, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
Date
.
Schema for JavaScript Date objects.
When to use
Use to validate in-memory values that must already be JavaScript date
objects.
Details
This schema accepts any Date instance, including invalid dates. The default
JSON serializer encodes valid dates as ISO 8601 strings; invalid dates encode
as "Invalid Date".
Example (Defining a Date schema)
import { Schema } from "effect"
Schema.decodeUnknownSync(Schema.Date)(new Date("2024-01-01"))
// => Date { 2024-01-01T00:00:00.000Z }
Date.Bottom<globalThis.Date, globalThis.Date, never, never, Declaration, declareConstructor<globalThis.Date, globalThis.Date, readonly [], globalThis.Date>, ... 8 more ..., "required">.check(checks_0: SchemaAST.Check<globalThis.Date>, ...checks: SchemaAST.Check<globalThis.Date>[]): Datecheck(function isDateValid(
annotations?: Annotations.Filter
): SchemaAST.Filter<globalThis.Date>
Validates that a Date object represents a valid date (not an invalid date
like new Date("invalid")).
Details
JSON Schema:
This check does not have a direct JSON Schema equivalent, as JSON Schema
validates date strings, not Date objects.
Arbitrary:
When generating test data with fast-check, this applies a valid: true
constraint to ensure generated Date objects are valid.
isDateValid())