Options used by shapes and built-in operations to create an issue.

Issue

interface MultipleOfOptions {
    message?:
        | null
        | string
        | number
        | bigint
        | boolean
        | symbol
        | object
        | MessageCallback;
    meta?: any;
    precision?: number;
}

Hierarchy (view full)

Properties

message?:
    | null
    | string
    | number
    | bigint
    | boolean
    | symbol
    | object
    | MessageCallback

The custom issue message.

meta?: any

An arbitrary metadata that is added to an issue.

precision?: number

The non-negative integer, the number of decimal digits that are considered significant for floating number comparison.

By default, NumberShape.multipleOf uses the modulo operator which may produce unexpected results when used with floating point numbers. This happens because of the way numbers are represented by IEEE 754.

For example, for small dividers such as 0.01 the result of the division is usually not integer (even when it should be integer). If you need to use fractional dividers set this option to some positive integer to have multipleOf validated using this formula:

Math.abs(Math.round(value / divisor) - value / divisor) <= Math.pow(10, -precision)