Basic schema that validates values against a set of validation rules.
More...
Basic schema that validates values against a set of validation rules.
This schema is used as a basis for specific schemas to validate objects, project properties, arrays and maps.
See ObjectSchema, PropertySchema, ArraySchema, MapSchema
◆ Schema() [1/2]
PipServices3.Commons.Validate.Schema.Schema |
( |
| ) |
|
Creates a new instance of validation schema.
◆ Schema() [2/2]
PipServices3.Commons.Validate.Schema.Schema |
( |
bool |
required, |
|
|
List< IValidationRule > |
rules |
|
) |
| |
Creates a new instance of validation schema and sets its values.
- Parameters
-
required | (optional) true to always require non-null values. |
rules | (optional) a list with validation rules. |
◆ MakeOptional()
Schema PipServices3.Commons.Validate.Schema.MakeOptional |
( |
| ) |
|
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.
- Returns
- this validation schema
◆ MakeRequired()
Schema PipServices3.Commons.Validate.Schema.MakeRequired |
( |
| ) |
|
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.
- Returns
- this validation schema
◆ PerformTypeValidation()
void PipServices3.Commons.Validate.Schema.PerformTypeValidation |
( |
string |
path, |
|
|
object |
type, |
|
|
object |
value, |
|
|
List< ValidationResult > |
results |
|
) |
| |
|
protected |
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.
- Parameters
-
path | a dot notation path to the value. |
type | a type to match the value type |
value | a value to be validated. |
results | a list with validation results to add new results. |
◆ Validate()
List<ValidationResult> PipServices3.Commons.Validate.Schema.Validate |
( |
object |
value | ) |
|
Validates the given value and results validation results.
- Parameters
-
value | a value to be validated. |
- Returns
- a list with validation results.
◆ ValidateAndThrowException()
void PipServices3.Commons.Validate.Schema.ValidateAndThrowException |
( |
string |
correlationId, |
|
|
object |
value, |
|
|
bool |
strict = false |
|
) |
| |
Validates the given value and returns a ValidationException if errors were found.
- Parameters
-
correlationId | (optional) transaction id to trace execution through call chain. |
value | a value to be validated. |
strict | true to treat warnings as errors. |
◆ WithRule()
Adds validation rule to this schema. This method returns reference to this exception to implement Builder pattern to chain additional calls.
- Parameters
-
rule | a validation rule to be added. |
- Returns
- this validation schema.
The documentation for this class was generated from the following file: