Creates a new validation schema and sets its values.
(optional) a property name
(optional) a property type
(optional) true to always require non-null values.
(optional) a list with validation rules.
Gets the property name.
the property name.
Gets validation rules to check values against.
a list with validation rules.
Gets the property type.
the property type.
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 the property name.
a new property name.
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.
Sets a new property type. The type can be defined as type, type name or TypeCode
a new property type.
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 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 object properties
ObjectSchema
Example
let schema = new ObjectSchema() .withProperty(new PropertySchema("id", 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