Represents an error that occurs during schema validation.

This error is thrown when input data fails to meet the constraints defined by a schema.

example

const schema = val.string().minLength(3); schema.validate("hi"); // Throws ValidationError // Example error message: // "ValidationError: String Failed Validation for: ✖ String is too short. Minimum length is 3."

Hierarchy

Index

Constructors

Properties

Constructors

constructor

  • Creates a new instance of ValidationError.

    example

    throw new ValidationError("Expected a string, but received a number.");

    Parameters

    • message: string

      A detailed message describing the validation failure.

    Returns ValidationError

Properties

message

message: string

name

name: string

Optional stack

stack: string

Static Error

Error: ErrorConstructor

Generated using TypeDoc