UNPKG

@cowwoc/requirements

Version:

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

32 lines (31 loc) 1.62 kB
import { type Configuration, type StringValidator, type ValidationFailure, type ApplicationScope, type UnsignedNumberValidator, AbstractValidator, ValidationTarget } from "../internal.mjs"; /** * Default implementation of `StringValidator`. */ declare class StringValidatorImpl<T extends string | undefined | null> extends AbstractValidator<T> implements StringValidator<T> { /** * @param scope - the application configuration * @param configuration - the validator configuration * @param name - the name of the value * @param value - the value * @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, name: string, value: ValidationTarget<T>, context: Map<string, unknown>, failures: ValidationFailure[]); isEmpty(): this; isNotEmpty(): this; isTrimmed(): this; startsWith(prefix: string): this; doesNotStartWith(prefix: string): this; endsWith(suffix: string): this; doesNotEndWith(suffix: string): this; contains(expected: string): this; doesNotContain(unwanted: string): this; doesNotContainWhitespace(): this; matches(regex: RegExp): this; length(): UnsignedNumberValidator; } export { StringValidatorImpl };