A map of property names to their respective schemas.
Indicates whether the schema allows undefined
as a valid value.
The type of data that the schema validates, represented as a string.
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 object schema.
The data to validate.
The validated object with all properties conforming to their respective schemas.
Generated using TypeDoc
Interface for validating object structures with defined schemas for each property.
const objectSchema = val.ObjectSchema({ name: val.StringSchema().minLength(3), age: val.NumberSchema().min(18), });
const validData = objectSchema.validate({ name: "John", age: 25 }); // Passes validation
ValidationError If the object does not match the schema.
const invalidData = { name: "Jo", age: 17 }; objectSchema.validate(invalidData); // Throws ValidationError // Example error message: // "Validation failed for property 'name': ✖ String is too short. Minimum length is 3 → at name" // "Validation failed for property 'age': ✖ Expected a number greater than or equal to 18 → at age"