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

Function makeIsMultipleOf

packages/effect/src/Schema.ts:7850–7867  ·  view source on GitHub ↗
(options: {
  readonly remainder: (input: T, divisor: T) => T
  readonly zero: NoInfer<T>
  readonly annotate?: ((divisor: T) => Annotations.Filter) | undefined
  readonly formatter?: Formatter<T> | undefined
})

Source from the content-addressed store, hash-verified

7848 * @since 4.0.0
7849 */
7850export function makeIsMultipleOf<T>(options: {
7851 readonly remainder: (input: T, divisor: T) => T
7852 readonly zero: NoInfer<T>
7853 readonly annotate?: ((divisor: T) => Annotations.Filter) | undefined
7854 readonly formatter?: Formatter<T> | undefined
7855}) {
7856 return (divisor: T, annotations?: Annotations.Filter) => {
7857 const formatter = options.formatter ?? format
7858 return makeFilter<T>(
7859 (input) => options.remainder(input, divisor) === options.zero,
7860 {
7861 expected: `a value that is a multiple of ${formatter(divisor)}`,
7862 ...options.annotate?.(divisor),
7863 ...annotations
7864 }
7865 )
7866 }
7867}
7868
7869function encodeNumberPayload(number: number): number {
7870 if (!globalThis.Number.isFinite(number)) {

Callers 1

Schema.tsFile · 0.85

Calls 2

makeFilterFunction · 0.85
annotateMethod · 0.65

Tested by

no test coverage detected