(
maximum: globalThis.Date,
annotations?: Annotations.Filter
): SchemaAST.Filter<globalThis.Date>Validates that a Date is less than or equal to the specified date (inclusive).
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 max constraint
to ensure generated Date objects are less than or equal to the specified
date.
export const const isLessThanOrEqualToDate: (
maximum: globalThis.Date,
annotations?: Annotations.Filter
) => SchemaAST.Filter<globalThis.Date>
Validates that a Date is less than or equal to the specified date
(inclusive).
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 max constraint
to ensure generated Date objects are less than or equal to the specified
date.
isLessThanOrEqualToDate = function makeIsLessThanOrEqualTo<
T
>(options: {
readonly order: Order.Order<T>
readonly annotate?:
| ((
exclusiveMaximum: T
) => Annotations.Filter)
| undefined
readonly formatter?: Formatter<T> | undefined
}): (
maximum: T,
annotations?: Annotations.Filter
) => SchemaAST.Filter<T>
Creates a less-than-or-equal-to (<=) check for any ordered type from an
Order.Order instance.
makeIsLessThanOrEqualTo({
order: Order.Order<globalThis.Date>order: import OrderOrder.const Date: Order<Date>Order instance for Date objects that compares them chronologically by their timestamp.
When to use
Use when you need chronological ordering for JavaScript date values.
Details
Compares dates by their underlying timestamp in milliseconds since the epoch.
Earlier dates are less than later dates. Invalid dates are compared through
their getTime() result.
Example (Ordering Dates)
import { Order } from "effect"
const date1 = new Date("2023-01-01")
const date2 = new Date("2023-01-02")
console.log(Order.Date(date1, date2)) // -1
console.log(Order.Date(date2, date1)) // 1
console.log(Order.Date(date1, date1)) // 0
Date,
annotate?: | ((
exclusiveMaximum: globalThis.Date
) => Annotations.Filter)
| undefined
annotate: (maximum: globalThis.Datemaximum) => ({
Annotations.Filter.meta?: Annotations.Meta | undefined(property) Annotations.Filter.meta?: {
_tag: 'isLessThanOrEqualToDate';
maximum: globalThis.Date;
}
Optional metadata used to identify or extend the filter with custom data.
meta: {
_tag: "isLessThanOrEqualToDate"_tag: "isLessThanOrEqualToDate",
maximum: globalThis.Datemaximum
}
})
})