(
options: {
readonly minimum: globalThis.Date
readonly maximum: globalThis.Date
readonly exclusiveMinimum?: boolean | undefined
readonly exclusiveMaximum?: boolean | undefined
},
annotations?: Annotations.Filter
): SchemaAST.Filter<globalThis.Date>Validates that a Date is within a specified range. The range boundaries can be inclusive or exclusive based on the provided options.
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 min and max
constraints to ensure generated Date objects fall within the specified range,
shifting exclusive bounds by one millisecond.
export const const isBetweenDate: (
options: {
readonly minimum: globalThis.Date
readonly maximum: globalThis.Date
readonly exclusiveMinimum?:
| boolean
| undefined
readonly exclusiveMaximum?:
| boolean
| undefined
},
annotations?: Annotations.Filter
) => SchemaAST.Filter<globalThis.Date>
Validates that a Date is within a specified range. The range boundaries can
be inclusive or exclusive based on the provided options.
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 min and max
constraints to ensure generated Date objects fall within the specified range,
shifting exclusive bounds by one millisecond.
isBetweenDate = function makeIsBetween<T>(deriveOptions: {
readonly order: Order.Order<T>
readonly annotate?:
| ((options: {
readonly minimum: T
readonly maximum: T
readonly exclusiveMinimum?:
| boolean
| undefined
readonly exclusiveMaximum?:
| boolean
| undefined
}) => Annotations.Filter)
| undefined
readonly formatter?: Formatter<T> | undefined
}): (
options: {
readonly minimum: T
readonly maximum: T
readonly exclusiveMinimum?:
| boolean
| undefined
readonly exclusiveMaximum?:
| boolean
| undefined
},
annotations?: Annotations.Filter
) => SchemaAST.Filter<T>
Creates an inclusive or exclusive range check for any ordered type from an
Order.Order instance.
makeIsBetween({
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?: | ((options: {
readonly minimum: globalThis.Date
readonly maximum: globalThis.Date
readonly exclusiveMinimum?:
| boolean
| undefined
readonly exclusiveMaximum?:
| boolean
| undefined
}) => Annotations.Filter)
| undefined
annotate: (options: {
readonly minimum: globalThis.Date
readonly maximum: globalThis.Date
readonly exclusiveMinimum?: boolean | undefined
readonly exclusiveMaximum?: boolean | undefined
}
options) => ({
Annotations.Filter.meta?: Annotations.Meta | undefined(property) Annotations.Filter.meta?: {
minimum: globalThis.Date;
maximum: globalThis.Date;
exclusiveMinimum: boolean | undefined;
exclusiveMaximum: boolean | undefined;
_tag: 'isBetweenDate';
}
Optional metadata used to identify or extend the filter with custom data.
meta: {
_tag: "isBetweenDate"_tag: "isBetweenDate",
...options: {
readonly minimum: globalThis.Date
readonly maximum: globalThis.Date
readonly exclusiveMinimum?: boolean | undefined
readonly exclusiveMaximum?: boolean | undefined
}
options
}
})
})