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

    Class Configuration

    Determines the behavior of a validator.

    Index

    Constructors

    • Creates a new configuration that:

      • Has an empty context.
      • Throws an error on failure.
      • Records the error stack trace when a validation failure occurs.
      • May include a diff that compares the actual and expected values.

      Parameters

      • allowDiff: boolean = true

        true if error messages may include a diff that compares actual and expected values

      • stringMappers: StringMappers = StringMappers.DEFAULT

        the configuration used to map contextual values to a string

      • recordStacktrace: boolean = true

        true if the error stack trace must be recorded when a validation failure occurs. If false, the error type remains the same, but the stack trace points to the invocation of elseGetError(). Users who only plan to list of failure messages instead of retrieving an error may see a performance improvement if this value is set to false.

      • throwOnFailure: boolean = true

        true if an error is thrown on validation failure

      • errorTransformer: (error: Error) => Error = ...

        a function that transforms the validation error before it is thrown or returned

      Returns Configuration

      TypeError if any of the arguments are undefined or null

    Properties

    DEFAULT: Configuration = ...

    The default configuration.

    Methods

    • Returns true if error messages may include a diff that compares actual and expected values.

      Returns boolean

      true by default

    • Returns a function that transforms validation errors before they are thrown or recorded.

      Returns (error: Error) => Error

      a function that transforms the validation error

    • Returns true if the error stack trace must be recorded when a validation failure occurs. If false, the error type remains the same, but the stack trace points to the invocation of elseGetError(). Users who only plan to list of failure messages instead of retrieving an error may see a performance improvement if this value is set to false.

      Returns boolean

      true if error stack traces must be recorded when a validation failure occurs

    • Returns the configuration used to map contextual values to a String. Supports common types such as arrays, numbers, collections, maps, paths and errors.

      Returns StringMappers

      a function that takes an object and returns the string representation of the object

    • Returns true if an error is thrown on validation failure.

      Returns boolean

      true if an error is thrown on validation failure