(
options: {
readonly minimum: number
readonly maximum: number
readonly exclusiveMinimum?: boolean | undefined
readonly exclusiveMaximum?: boolean | undefined
},
annotations?: Annotations.Filter
): SchemaAST.Filter<number>Validates that a number is within a specified range. The range boundaries can be inclusive or exclusive based on the provided options.
Details
JSON Schema:
This check corresponds to minimum/maximum or exclusiveMinimum/exclusiveMaximum
constraints in JSON Schema, depending on the options provided.
Arbitrary:
When generating test data with fast-check, this applies minimum and
maximum constraints with optional exclusiveMinimum and
exclusiveMaximum flags to ensure generated numbers fall within the
specified range.
export const const isBetween: (
options: {
readonly minimum: number
readonly maximum: number
readonly exclusiveMinimum?:
| boolean
| undefined
readonly exclusiveMaximum?:
| boolean
| undefined
},
annotations?: Annotations.Filter
) => SchemaAST.Filter<number>
Validates that a number is within a specified range. The range boundaries can
be inclusive or exclusive based on the provided options.
Details
JSON Schema:
This check corresponds to minimum/maximum or exclusiveMinimum/exclusiveMaximum
constraints in JSON Schema, depending on the options provided.
Arbitrary:
When generating test data with fast-check, this applies minimum and
maximum constraints with optional exclusiveMinimum and
exclusiveMaximum flags to ensure generated numbers fall within the
specified range.
isBetween = 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<number>order: import OrderOrder.const Number: Order<number>Order instance for numbers that compares them numerically.
When to use
Use when you need numeric ordering for numbers.
Details
0 is considered equal to -0. All NaN values are considered equal to
each other, and any NaN is considered less than any non-NaN number. All
other values use standard numeric comparison.
Example (Ordering numbers)
import { Order } from "effect"
console.log(Order.Number(1, 1)) // 0
console.log(Order.Number(1, 2)) // -1
console.log(Order.Number(2, 1)) // 1
console.log(Order.Number(0, -0)) // 0
console.log(Order.Number(NaN, 1)) // -1
Number,
annotate?: | ((options: {
readonly minimum: number
readonly maximum: number
readonly exclusiveMinimum?:
| boolean
| undefined
readonly exclusiveMaximum?:
| boolean
| undefined
}) => Annotations.Filter)
| undefined
annotate: (options: {
readonly minimum: number
readonly maximum: number
readonly exclusiveMinimum?: boolean | undefined
readonly exclusiveMaximum?: boolean | undefined
}
options) => {
return {
Annotations.Filter.meta?: Annotations.Meta | undefined(property) Annotations.Filter.meta?: {
minimum: number;
maximum: number;
exclusiveMinimum: boolean | undefined;
exclusiveMaximum: boolean | undefined;
_tag: 'isBetween';
}
Optional metadata used to identify or extend the filter with custom data.
meta: {
_tag: "isBetween"_tag: "isBetween",
...options: {
readonly minimum: number
readonly maximum: number
readonly exclusiveMinimum?: boolean | undefined
readonly exclusiveMaximum?: boolean | undefined
}
options
}
}
}
})