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

    Interface JavascriptCheckIf

    Creates validators for the Javascript API that capture errors on validation failure rather than throwing them immediately.

    interface JavascriptCheckIf {
        checkIf<T>(value: T, name: string): UnknownValidator<T>;
        checkIfArray<T extends undefined | null | E[], E>(
            value: T,
            name: string,
        ): ArrayValidator<T, E>;
        checkIfBoolean<T extends undefined | null | boolean>(
            value: T,
            name: string,
        ): BooleanValidator<T>;
        checkIfMap<T extends undefined | null | Map<K, V>, K, V>(
            value: T,
            name: string,
        ): MapValidator<T, K, V>;
        checkIfNumber<T extends undefined | null | number>(
            value: T,
            name: string,
        ): NumberValidator<T>;
        checkIfSet<T extends undefined | null | Set<E>, E>(
            value: T,
            name: string,
        ): SetValidator<T, E>;
        checkIfString<T extends undefined | null | string>(
            value: T,
            name: string,
        ): StringValidator<T>;
    }

    Implemented by

    Index

    Methods

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

      The returned validator captures errors on validation failure rather than throwing them immediately. These errors can be retrieved or thrown once the validation completes. Errors unrelated to validation failures are thrown immediately.

      Type Parameters

      • T

        the type of the value

      Parameters

      • value: T

        the value

      • name: string

        the name of the value

      Returns UnknownValidator<T>

      a validator for the value

      TypeError if name is undefined or null

      RangeError if name contains whitespace or is empty

    • Validates the state of an array.

      The returned validator captures errors on validation failure rather than throwing them immediately. These errors can be retrieved or thrown once the validation completes. Errors unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | E[]

        the type of the value

      • E

        the type of elements in the collection

      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 contains whitespace or is empty

    • Validates the state of a boolean.

      The returned validator captures errors on validation failure rather than throwing them immediately. These errors can be retrieved or thrown once the validation completes. Errors unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | boolean

        the type of the value

      Parameters

      • value: T

        the value

      • name: string

        the name of the value

      Returns BooleanValidator<T>

      a validator for the value

      TypeError if name is undefined or null

      RangeError if name contains whitespace or is empty

    • Validates the state of a Map.

      The returned validator captures errors on validation failure rather than throwing them immediately. These errors can be retrieved or thrown once the validation completes. Errors unrelated to validation failures are thrown immediately.

      Type Parameters

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

        the type of 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 contains whitespace or is empty

    • Validates the state of a number.

      The returned validator captures errors on validation failure rather than throwing them immediately. These errors can be retrieved or thrown once the validation completes. Errors unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | number

        the type of the value

      Parameters

      • value: T

        the value

      • name: string

        the name of the value

      Returns NumberValidator<T>

      a validator for the value

      TypeError if name is undefined or null

      RangeError if name contains whitespace or is empty

    • Validates the state of a Set.

      The returned validator captures errors on validation failure rather than throwing them immediately. These errors can be retrieved or thrown once the validation completes. Errors unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | Set<E>

        the type of the value

      • E

        the type of elements in the set

      Parameters

      • value: T

        the value

      • name: string

        the name of the value

      Returns SetValidator<T, E>

      a validator for the value

      TypeError if name is undefined or null

      RangeError if name contains whitespace or is empty

    • Validates the state of a string.

      The returned validator captures errors on validation failure rather than throwing them immediately. These errors can be retrieved or thrown once the validation completes. Errors unrelated to validation failures are thrown immediately.

      Type Parameters

      • T extends undefined | null | string

        the type of the value

      Parameters

      • value: T

        the value

      • name: string

        the name of the value

      Returns StringValidator<T>

      a validator for the value

      TypeError if name is undefined or null

      RangeError if name contains whitespace or is empty