@cowwoc/requirements - v4.0.12
    Preparing search index...

    The default implementation of JavascriptValidators.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    context: Map<string, unknown> = ...
    INTERNAL: JavascriptValidatorsImpl = ...

    A validator factory that creates validators to check the arguments of validation methods.

    Methods

    • Validates the state of an unknown value or a value that does not have a specialized validator.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters

      • T

        the type the value

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns UnknownValidator<T>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of an array.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | E[]

        the type the value

      • E

        the type elements in the array

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns ArrayValidator<T, E>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of a boolean.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | boolean

        the type the value

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns BooleanValidator<T>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of a map.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | Map<K, V>

        the type the value

      • K

        the type of keys in the map

      • V

        the type of values in the map

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns MapValidator<T, K, V>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of a number.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | number

        the type the value

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns NumberValidator<T>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of a set.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | Set<E>

        the type the value

      • E

        the type elements in the set

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns SetValidator<T, E>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of a string.

      The returned validator captures exceptions on validation failure rather than throwing them immediately. The exceptions are converted into an AssertionError and can be retrieved or thrown once the validation completes. Exceptions unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | string

        the type the value

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns StringValidator<T>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of an array.

      The returned validator throws an error immediately if a validation fails.

      Type Parameters

      • T extends undefined | null | E[]

        the type the value

      • E

        the type elements in the array

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns ArrayValidator<T, E>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of a map.

      The returned validator throws an error immediately if a validation fails.

      Type Parameters

      • T extends undefined | null | Map<K, V>

        the type the value

      • K

        the type of keys in the map

      • V

        the type of values in the map

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns MapValidator<T, K, V>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of a number.

      The returned validator throws an error immediately if a validation fails.

      Type Parameters

      • T extends undefined | null | number

        the type the value

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns NumberValidator<T>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of a set.

      The returned validator throws an error immediately if a validation fails.

      Type Parameters

      • T extends undefined | null | Set<E>

        the type the value

      • E

        the type elements in the set

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns SetValidator<T, E>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of a string.

      The returned validator throws an error immediately if a validation fails.

      Type Parameters

      • T extends undefined | null | string

        the type the value

      Parameters

      • value: T

        the value

      • Optionalname: string

        the name of the value

      Returns StringValidator<T>

      validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Returns the contextual information inherited by validators created out by this factory. The contextual information is a map of key-value pairs that can provide more details about validation failures. For example, if the message is "Password may not be empty" and the map contains the key-value pair {"username": "john.smith"}, the error message would be:

      Password may not be empty
      username: john.smith

      Returns Map<string, unknown>

      an unmodifiable map from each entry's name to its value

    • Validates the state of an array.

      The returned validator throws an error immediately if a validation fails.

      Type Parameters

      • T extends undefined | null | E[]

        the type the value

      • E

        the type elements in the array

      Parameters

      • value: T

        the value

      • name: string

        the name of the value

      Returns ArrayValidator<T, E>

      a validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty

    • Validates the state of a map.

      The returned validator throws an error immediately if a validation fails.

      Type Parameters

      • T extends undefined | null | Map<K, V>

        the type the value

      • K

        the type of keys in the map

      • V

        the type of values in the map

      Parameters

      • value: T

        the value

      • name: string

        the name of the value

      Returns MapValidator<T, K, V>

      a validator for the value

      TypeError if name is undefined or null

      RangeError if name is empty