Creates a new validation schema and sets its values.
true to allow properties undefines in the schema
(optional) true to always require non-null values.
(optional) a list with validation rules.
Gets flag to allow undefined properties
true to allow undefined properties and false to disallow.
Sets flag to allow undefined properties
true to allow undefined properties and false to disallow.
true to allow undefined properties and false to disallow.
Sets flag to allow undefined properties
This method returns reference to this exception to implement Builder pattern to chain additional calls.
true to allow undefined properties and false to disallow.
this validation schema.
Gets validation schemas for object properties.
the list of property validation schemas.
Gets validation rules to check values against.
a list with validation rules.
Gets a flag that always requires non-null values. For null values it raises a validation error.
true to always require non-null values and false to allow null values.
Makes validated values optional. Validation for null values will be skipped.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
this validation schema
Makes validated values always required (non-null). For null values the schema will raise errors.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
this validation schema
Validates a given value to match specified type. The type can be defined as a Schema, type, a type name or TypeCode When type is a Schema, it executes validation recursively against that Schema.
a dot notation path to the value.
a type to match the value type
a value to be validated.
a list with validation results to add new results.
Validates a given value against the schema and configured validation rules.
a dot notation path to the value.
a value to be validated.
a list with validation results to add new results.
Sets validation schemas for object properties.
a list of property validation schemas.
Sets a flag that always requires non-null values.
true to always require non-null values and false to allow null values.
Sets validation rules to check values against.
a list with validation rules.
Validates the given value and results validation results.
a value to be validated.
a list with validation results.
Validates the given value and returns a ValidationException if errors were found.
(optional) transaction id to trace execution through call chain.
a value to be validated.
true to treat warnings as errors.
Validates the given value and throws a ValidationException if errors were found.
(optional) transaction id to trace execution through call chain.
a value to be validated.
true to treat warnings as errors.
Adds a validation schema for an optional object property.
a property name.
(optional) a property schema or type.
(optional) a list of property validation rules.
Adds a validation schema for an object property.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
a property validation schema to be added.
this validation schema.
Adds a validation schema for a required object property.
a property name.
(optional) a property schema or type.
(optional) a list of property validation rules.
Adds validation rule to this schema.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
a validation rule to be added.
this validation schema.
Generated using TypeDoc
Schema to validate user defined objects.
Example
let schema = new ObjectSchema(false) .withOptionalProperty("id", TypeCode.String) .withRequiredProperty("name", TypeCode.String); schema.validate({ id: "1", name: "ABC" }); // Result: no errors schema.validate({ name: "ABC" }); // Result: no errors schema.validate({ id: 1, name: "ABC" }); // Result: id type mismatch schema.validate({ id: 1, _name: "ABC" }); // Result: name is missing, unexpected _name schema.validate("ABC"); // Result: type mismatch