import { AbstractValidator } from '../types'; import type { Branding } from '../types'; /** Constraints to validate a `number` with. */ export interface NumberConstraints { /** The value for which a `number` must be multiple of for it to be valid */ multipleOf?: number; /** The _inclusive_ maximum value for a valid `number`: `value <= maximum` */ maximum?: number; /** The _inclusive_ minimum value for a valid `number`: `value >= minimum` */ minimum?: number; /** The _exclusive_ maximum value for a valid `number`: `value < exclusiveMaximum` */ exclusiveMaximum?: number; /** The _exclusive_ minimum value for a valid `number`: `value > exclusiveMaximum` */ exclusiveMinimum?: number; /** Allow numbers to be parsed from strings (e.g. `123.456` or `0x0CAFE`, default: `false`) */ fromString?: boolean; /** Whether to allow `NaN` or not (default: `false`) */ allowNaN?: boolean; } /** Constraints to validate a `number` with extra branding information. */ export interface BrandedNumberConstraints extends NumberConstraints { /** The _brand_ of the string (will generate a `__brand_${B}` type property */ brand: B; } /** A `Validator` validating any `number`. */ export declare class AnyNumberValidator extends AbstractValidator { validate(value: unknown): number; } /** A `Validator` validating `number`s with constaints. */ export declare class NumberValidator extends AbstractValidator { #private; readonly allowNaN: boolean; readonly exclusiveMaximum?: number; readonly exclusiveMinimum?: number; readonly fromString: boolean; readonly maximum: number; readonly minimum: number; readonly multipleOf?: number; readonly brand?: string; constructor(constraints?: NumberConstraints); validate(value: unknown): N; } export declare function numberValidatorFactory(constraints: NumberConstraints): NumberValidator; export declare function numberValidatorFactory(constraints: NumberConstraints): NumberValidator; export declare function numberValidatorFactory(constraints: BrandedNumberConstraints): NumberValidator>; /** Validate `number`s. */ export declare const number: typeof numberValidatorFactory & AnyNumberValidator;