UNPKG

@cowwoc/requirements

Version:

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

65 lines (64 loc) 3.7 kB
import { AbstractValidator, MessageBuilder, StringMappers } from "../internal.mjs"; /** * @param validator - the validator * @param expectedName - the name of the expected value * @param expected - the expected value * @returns a message for the validation failure */ declare function comparableIsEqualTo(validator: AbstractValidator<unknown>, expectedName: string | null, expected: unknown): MessageBuilder; /** * @param validator - the validator * @param limitName - the name of the value's bound * @param maximumExclusive - the exclusive upper bound * @returns a message for the validation failure */ declare function comparableIsLessThan(validator: AbstractValidator<unknown>, limitName: string | null, maximumExclusive: unknown): MessageBuilder; /** * @param validator - the validator * @param limitName - the name of the value's bound * @param maximumInclusive - the inclusive upper bound * @returns a message for the validation failure */ declare function comparableIsLessThanOrEqualTo(validator: AbstractValidator<unknown>, limitName: string | null, maximumInclusive: unknown): MessageBuilder; /** * @param validator - the validator * @param limitName - the name of the value's bound * @param minimumInclusive - the inclusive lower bound * @returns a message for the validation failure */ declare function comparableIsGreaterThanOrEqualTo(validator: AbstractValidator<unknown>, limitName: string | null, minimumInclusive: unknown): MessageBuilder; /** * @param validator - the validator * @param limitName - the name of the value's bound * @param minimumExclusive - the exclusive lower bound * @returns a message for the validation failure */ declare function comparableIsGreaterThan(validator: AbstractValidator<unknown>, limitName: string | null, minimumExclusive: unknown): MessageBuilder; /** * @param validator - the validator * @param relationship - a description of the relationship between the actual and expected value (e.g. "must * be equal to") * @param expectedName - the name of the expected value * @param expected - the expected value * @returns a message for the validation failure */ declare function comparableCompareValues(validator: AbstractValidator<unknown>, relationship: string, expectedName: string | null, expected: unknown): MessageBuilder; /** * @param validator - the validator * @param minimum - the object representation of the lower limit * @param minimumInclusive - `true` if the lower bound of the range is inclusive * @param maximum - the object representation of the upper limit * @param maximumInclusive - `true` if the upper bound of the range is inclusive * @returns a message for the validation failure */ declare function isBetweenFailed(validator: AbstractValidator<unknown>, minimum: unknown, minimumInclusive: boolean, maximum: unknown, maximumInclusive: boolean): MessageBuilder; /** * @param minimum - the Object representation of the lower limit * @param minimumInclusive - `true` if the lower bound of the range is inclusive * @param maximum - the Object representation of the upper limit * @param maximumInclusive - `true` if the upper bound of the range is inclusive * @param stringMappers - the configuration used to map contextual values to a String * @returns a message for the validation failure */ declare function comparableGetBounds(minimum: unknown, minimumInclusive: boolean, maximum: unknown, maximumInclusive: boolean, stringMappers: StringMappers): string; export { comparableIsEqualTo, comparableIsLessThan, comparableIsLessThanOrEqualTo, comparableIsGreaterThanOrEqualTo, comparableIsGreaterThan, comparableCompareValues, isBetweenFailed, comparableGetBounds };