MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeIsLessThanOrEqualTo

Function makeIsLessThanOrEqualTo

packages/effect/src/Schema.ts:7760–7785  ·  view source on GitHub ↗
(options: {
  readonly order: Order.Order<T>
  readonly annotate?: ((exclusiveMaximum: T) => Annotations.Filter) | undefined
  readonly formatter?: Formatter<T> | undefined
})

Source from the content-addressed store, hash-verified

7758 * @since 4.0.0
7759 */
7760export 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

Callers 1

Schema.tsFile · 0.85

Calls 3

makeFilterFunction · 0.85
lteFunction · 0.85
annotateMethod · 0.65

Tested by

no test coverage detected