(options: {
readonly order: Order.Order<T>
readonly annotate?: ((exclusiveMaximum: T) => Annotations.Filter) | undefined
readonly formatter?: Formatter<T> | undefined
})
| 7758 | * @since 4.0.0 |
| 7759 | */ |
| 7760 | export function makeIsLessThanOrEqualTo<T>(options: { |
| 7761 | readonly order: Order.Order<T> |
| 7762 | readonly annotate?: ((exclusiveMaximum: T) => Annotations.Filter) | undefined |
| 7763 | readonly formatter?: Formatter<T> | undefined |
| 7764 | }) { |
| 7765 | const lte = Order.isLessThanOrEqualTo(options.order) |
| 7766 | const formatter = options.formatter ?? format |
| 7767 | return (maximum: T, annotations?: Annotations.Filter) => { |
| 7768 | return makeFilter<T>( |
| 7769 | (input) => lte(input, maximum), |
| 7770 | { |
| 7771 | expected: `a value less than or equal to ${formatter(maximum)}`, |
| 7772 | arbitrary: { |
| 7773 | constraint: { |
| 7774 | ordered: { |
| 7775 | order: options.order, |
| 7776 | maximum |
| 7777 | } |
| 7778 | } |
| 7779 | }, |
| 7780 | ...options.annotate?.(maximum), |
| 7781 | ...annotations |
| 7782 | } |
| 7783 | ) |
| 7784 | } |
| 7785 | } |
| 7786 | |
| 7787 | /** |
| 7788 | * Creates an inclusive or exclusive range check for any ordered type from an |
no test coverage detected