@cowwoc/requirements
Version:
A fluent API for enforcing design contracts with automatic message generation.
118 lines (117 loc) • 6.82 kB
text/typescript
import { AbstractValidator, MessageBuilder, Pluralizer, Difference } from "../internal.mjs";
/**
* @param validator - the collection's validator
* @param actualSizeName - the name of the collection's size
* @param actualSize - the collection's size
* @param relationship - the relationship between the actual and expected sizes (e.g. "must contain less
* than")
* @param expectedSizeName - an expression representing the expected size of the collection
* @param expectedSize - the number of elements that should be in the collection
* @param pluralizer - the type of items in the collection
* @returns a message for the validation failure
*/
declare function collectionContainsSize(validator: AbstractValidator<unknown>, actualSizeName: string, actualSize: number | null, relationship: string, expectedSizeName: string | null, expectedSize: number, pluralizer: Pluralizer): MessageBuilder;
/**
* @param validator - the collection's validator
* @param actualSizeName - the name of the collection's size
* @param actualSize - the collection's size
* @param minimum - the collection's minimum size
* @param minimumInclusive - `true` if minimum size is inclusive
* @param maximum - the collection's maximum size
* @param maximumInclusive - `true` if maximum size is inclusive
* @param pluralizer - the type of items in the collection
*/
declare function collectionSizeIsBetween(validator: AbstractValidator<unknown>, actualSizeName: string, actualSize: number | null, minimum: number, minimumInclusive: boolean, maximum: number, maximumInclusive: boolean, pluralizer: Pluralizer): MessageBuilder;
/**
* @param validator - the validator
* @returns a message for the validation failure
*/
declare function collectionIsEmpty(validator: AbstractValidator<unknown>): MessageBuilder;
/**
* @param validator - the validator
* @returns a message for the validation failure
*/
declare function collectionIsNotEmpty(validator: AbstractValidator<unknown>): MessageBuilder;
/**
* @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 collectionContains(validator: AbstractValidator<unknown>, expectedName: string | null, expected: unknown): MessageBuilder;
/**
* @param validator - the validator
* @param unwantedName - the name of the unwanted value
* @param unwanted - the unwanted value
* @returns a message for the validation failure
*/
declare function collectionDoesNotContain(validator: AbstractValidator<unknown>, unwantedName: string | null, unwanted: unknown): MessageBuilder;
/**
* @param validator - the validator
* @param expectedName - the name of the expected collection
* @param expected - the collection of expected values
* @param pluralizer - the type of items in the collections
* @returns a message for the validation failure
*/
declare function collectionContainsAny(validator: AbstractValidator<unknown>, expectedName: string | null, expected: unknown, pluralizer: Pluralizer): MessageBuilder;
/**
* @typeParam E - the type of elements in the value
* @param validator - the validator
* @param difference - the difference between the actual and unwanted values
* @param unwantedName - the name of the unwanted collection
* @param unwanted - the collection of unwanted elements
* @param pluralizer - the type of items in the collections
* @returns a message for the validation failure
*/
declare function collectionDoesNotContainAny<E>(validator: AbstractValidator<unknown>, difference: Difference<E> | null, unwantedName: string | null, unwanted: unknown, pluralizer: Pluralizer): MessageBuilder;
/**
* @typeParam E - the type of elements in the value
* @param validator - the validator
* @param difference - the difference between the actual and expected values
* @param expectedName - the name of the collection
* @param expected - the collection
* @param pluralizer - the type of items in the value
* @returns a message for the validation failure
*/
declare function collectionContainsExactly<E>(validator: AbstractValidator<unknown>, difference: Difference<E> | null, expectedName: string | null, expected: unknown, pluralizer: Pluralizer): MessageBuilder;
/**
* @param validator - the validator
* @param unwantedName - the name of the collection
* @param unwanted - the collection
* @param pluralizer - the type of items in the value
* @returns a message for the validation failure
*/
declare function collectionDoesNotContainExactly(validator: AbstractValidator<unknown>, unwantedName: string | null, unwanted: unknown, pluralizer: Pluralizer): MessageBuilder;
/**
* @typeParam E - the type of elements in the value
* @param validator - the validator
* @param difference - the difference between the actual and expected values
* @param expectedName - the name of the expected collection
* @param expected - the collection of expected values
* @param pluralizer - the type of items in the value
* @returns a message for the validation failure
*/
declare function collectionContainsAll<E>(validator: AbstractValidator<unknown>, difference: Difference<E> | null, expectedName: string | null, expected: unknown, pluralizer: Pluralizer): MessageBuilder;
/**
* @param validator - the validator
* @param unwantedName - the name of the unwanted collection
* @param unwanted - the collection of unwanted values
* @param pluralizer - the type of items in the value
* @returns a message for the validation failure
*/
declare function collectionDoesNotContainAll(validator: AbstractValidator<unknown>, unwantedName: string | null, unwanted: unknown, pluralizer: Pluralizer): MessageBuilder;
/**
* @typeParam E - the type of elements in the value
* @param validator - the validator
* @param duplicates - the duplicate values in the value being validated
* @param pluralizer - the type of items in the value
* @returns a message for the validation failure
*/
declare function collectionDoesNotContainDuplicates<E>(validator: AbstractValidator<unknown>, duplicates: Set<E> | null, pluralizer: Pluralizer): MessageBuilder;
/**
* @param validator - the validator
* @param sorted - the sorted representation of the value being validated
* @returns a message for the validation failure
*/
declare function collectionIsSorted(validator: AbstractValidator<unknown>, sorted: unknown[] | null): MessageBuilder;
export { collectionContainsSize, collectionSizeIsBetween, collectionIsEmpty, collectionIsNotEmpty, collectionContains, collectionDoesNotContain, collectionContainsExactly, collectionDoesNotContainExactly, collectionContainsAny, collectionDoesNotContainAny, collectionContainsAll, collectionDoesNotContainAll, collectionDoesNotContainDuplicates, collectionIsSorted };