Hyperlinkv0.8.0-beta.28

Schema

Schema.isDateValidfunctioneffect/Schema.ts:7616
(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.

Date checks
Source effect/Schema.ts:761617 lines
export function isDateValid(annotations?: Annotations.Filter) {
  return makeFilter<globalThis.Date>(
    (date) => !isNaN(date.getTime()),
    {
      expected: "a valid date",
      meta: {
        _tag: "isDateValid"
      },
      arbitrary: {
        constraint: {
          valid: true
        }
      },
      ...annotations
    }
  )
}
Referenced by 2 symbols