(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
})
| 7792 | * @since 4.0.0 |
| 7793 | */ |
| 7794 | export function makeIsBetween<T>(deriveOptions: { |
| 7795 | readonly order: Order.Order<T> |
| 7796 | readonly annotate?: |
| 7797 | | ((options: { |
| 7798 | readonly minimum: T |
| 7799 | readonly maximum: T |
| 7800 | readonly exclusiveMinimum?: boolean | undefined |
| 7801 | readonly exclusiveMaximum?: boolean | undefined |
| 7802 | }) => Annotations.Filter) |
| 7803 | | undefined |
| 7804 | readonly formatter?: Formatter<T> | undefined |
| 7805 | }) { |
| 7806 | const greaterThanOrEqualTo = Order.isGreaterThanOrEqualTo(deriveOptions.order) |
| 7807 | const greaterThan = Order.isGreaterThan(deriveOptions.order) |
| 7808 | const lessThanOrEqualTo = Order.isLessThanOrEqualTo(deriveOptions.order) |
| 7809 | const lessThan = Order.isLessThan(deriveOptions.order) |
| 7810 | const formatter = deriveOptions.formatter ?? format |
| 7811 | return (options: { |
| 7812 | readonly minimum: T |
| 7813 | readonly maximum: T |
| 7814 | readonly exclusiveMinimum?: boolean | undefined |
| 7815 | readonly exclusiveMaximum?: boolean | undefined |
| 7816 | }, annotations?: Annotations.Filter) => { |
| 7817 | const gte = options.exclusiveMinimum ? greaterThan : greaterThanOrEqualTo |
| 7818 | const lte = options.exclusiveMaximum ? lessThan : lessThanOrEqualTo |
| 7819 | return makeFilter<T>( |
| 7820 | (input) => gte(input, options.minimum) && lte(input, options.maximum), |
| 7821 | { |
| 7822 | expected: `a value between ${formatter(options.minimum)}${options.exclusiveMinimum ? " (excluded)" : ""} and ${ |
| 7823 | formatter(options.maximum) |
| 7824 | }${options.exclusiveMaximum ? " (excluded)" : ""}`, |
| 7825 | arbitrary: { |
| 7826 | constraint: { |
| 7827 | ordered: { |
| 7828 | order: deriveOptions.order, |
| 7829 | minimum: options.minimum, |
| 7830 | maximum: options.maximum, |
| 7831 | ...(options.exclusiveMinimum && { exclusiveMinimum: true }), |
| 7832 | ...(options.exclusiveMaximum && { exclusiveMaximum: true }) |
| 7833 | } |
| 7834 | } |
| 7835 | }, |
| 7836 | ...deriveOptions.annotate?.(options), |
| 7837 | ...annotations |
| 7838 | } |
| 7839 | ) |
| 7840 | } |
| 7841 | } |
| 7842 | |
| 7843 | /** |
| 7844 | * Creates a divisibility check for any numeric type from a remainder function |
no test coverage detected