The type of the enumerated values (string or number).
Indicates whether the schema allows undefined
as a valid value.
The type of data that the schema validates, represented as a string.
Coerces the input into one of the enumerated values.
The current schema instance.
Retrieves the list of valid enumerated values.
An array of valid enumerated values.
Marks the schema as optional, allowing undefined
as a valid value.
The current schema instance.
Parses the input data and returns the parsed value.
This method is typically used to coerce or transform the input data into the desired format.
The input data to parse.
The parsed value.
Validates the input data against the enumeration schema.
The data to validate.
The validated enumerated value.
Generated using TypeDoc
Interface for validating enumerated values.
const enumSchema = val.EnumSchema(['A', 'B', 'C']); enumSchema.validate('A'); // Validates that the input is one of the enumerated values.
ValidationError If the input is not in the enumeration.
// Example error message: // "Enum Failed Validation for: ✖ Expected one of ['A', 'B', 'C'], but received 'D'."