Validation Rules
Add validation to your schemas with comprehensive field-level and cross-field rules. Maintain data quality with custom messages and severity levels.
Validation rules verify that data meets requirements before processing. The schema editor includes comprehensive field-level and cross-field rules, covering everything from simple required checks to complex conditional validation.
Adding Validation Rules
General Rules
These rules apply to all field types.
| Rule | Description |
|---|---|
| required | Field must be present |
| nullable | Allow null values |
| const | Must equal a specific value |
| enum | Value must be in an allowed list |
| notEnum | Value must not be in a forbidden list |
| format | Must match a specific format |
| type | Must match expected type |
| custom | Custom validation expression |
String Rules
Validation rules specific to string fields.
The following schemas demonstrate pattern validation with custom error messages:
Numeric Rules
Validation rules for integer and number fields.
Boolean Rules
| Rule | Description |
|---|---|
| required | Field must be present |
| mustBeTrue | Value must be true |
| mustBeFalse | Value must be false |
| const | Must equal specific boolean value |
Array Rules
| Rule | Description |
|---|---|
| minItems | Minimum number of items |
| maxItems | Maximum number of items |
| uniqueItems | All items must be unique |
| contains | Array must contain specific value |
| allowEmpty | Whether empty arrays are valid |
Object Rules
| Rule | Description |
|---|---|
| minProperties | Minimum number of properties |
| maxProperties | Maximum number of properties |
| requiredProperty | Specific property must exist |
| forbiddenProperty | Specific property must not exist |
| propertyPattern | Property names must match pattern |
| dependencies | Property dependencies |
Cross-Field Validation
Cross-field rules validate relationships between multiple fields. Add these in the Cross-Field Validation section of the schema editor.
Custom Error Messages
Each validation rule can have a custom error message with the following properties.