Hyperlinkv0.8.0-beta.28

Schema

Schema.makeIsMultipleOffunctioneffect/Schema.ts:7304
<T>(options: {
  readonly remainder: (input: T, divisor: T) => T
  readonly zero: NoInfer<T>
  readonly annotate?: ((divisor: T) => Annotations.Filter) | undefined
  readonly formatter?: Formatter<T> | undefined
}): (divisor: T, annotations?: Annotations.Filter) => SchemaAST.Filter<T>

Creates a divisibility check for any numeric type from a remainder function and a zero value.

Numeric checks
Source effect/Schema.ts:730418 lines
export function makeIsMultipleOf<T>(options: {
  readonly remainder: (input: T, divisor: T) => T
  readonly zero: NoInfer<T>
  readonly annotate?: ((divisor: T) => Annotations.Filter) | undefined
  readonly formatter?: Formatter<T> | undefined
}) {
  return (divisor: T, annotations?: Annotations.Filter) => {
    const formatter = options.formatter ?? format
    return makeFilter<T>(
      (input) => options.remainder(input, divisor) === options.zero,
      {
        expected: `a value that is a multiple of ${formatter(divisor)}`,
        ...options.annotate?.(divisor),
        ...annotations
      }
    )
  }
}
Referenced by 1 symbols