UNPKG

@cowwoc/requirements

Version:

A fluent API for enforcing design contracts with automatic message generation.

51 lines (50 loc) 2.7 kB
import { type Configuration, type Pluralizer, type ValidationFailure, type ApplicationScope, AbstractValidator, type UnsignedNumberValidator, ValidationTarget } from "../internal.mjs"; /** * Validates the state of an object's size. */ declare class ObjectSizeValidatorImpl extends AbstractValidator<number> implements UnsignedNumberValidator { private readonly objectValidator; private readonly pluralizer; /** * @param scope - the application configuration * @param configuration - the validator configuration * @param objectValidator - the object's validator * @param sizeName - the name of the object's size * @param size - the object's size * @param pluralizer - the type of elements in the object * @param context - the contextual information set by a parent validator or the user * @param failures - the list of validation failures * @throws TypeError if `name` is `undefined` or `null` * @throws RangeError if `name` contains whitespace, or is empty * @throws AssertionError if `scope`, `configuration`, `value`, `context` or `failures` are null */ constructor(scope: ApplicationScope, configuration: Configuration, objectValidator: AbstractValidator<unknown>, sizeName: string, size: ValidationTarget<number>, pluralizer: Pluralizer, context: Map<string, unknown>, failures: ValidationFailure[]); isEqualTo(expected: unknown): this; isNotEqualTo(unwanted: unknown): this; isZero(): this; isNotZero(): this; isPositive(): this; isNotPositive(): this; isLessThan(maximumExclusive: number): this; isLessThanOrEqualTo(maximumInclusive: number): this; isGreaterThanOrEqualTo(minimumInclusive: number): this; isGreaterThan(minimumExclusive: number): this; isBetween(minimumInclusive: number, maximumExclusive: number): this; isBetween(minimum: number, minimumIsInclusive: boolean, maximum: number, maximumIsInclusive: boolean): this; /** * @param value - the value being validated * @param minimum - the lower bound of the range * @param minimumIsInclusive - `true` if the lower bound of the range is inclusive * @param maximum - the upper bound of the range * @param maximumIsInclusive - `true` if the upper bound of the range is inclusive * @returns `true` if the value is in bounds; false otherwise */ private static inBounds; isMultipleOf(factor: number): this; isNotMultipleOf(factor: number): this; isFinite(): this; isInfinite(): this; isNumber(): this; isNotNumber(): this; } export { ObjectSizeValidatorImpl };