When calling handleValidation, you receive a ValidationResult. If validation fails, the formErrors property will contain a FormErrors object.
FormErrors Structure
FormErrors is a recursive object where keys are field names and values are either:
- A
string (the error message). - A nested
FormErrors object (for nested properties). - An
Array<null | FormErrors> (for array/group-array fields).
Custom Error Messages
You can define custom error messages in your JSON schema using the x-jsf-errorMessage key, mapped to the specific validation type:
{
"type": "string",
"x-jsf-errorMessage": {
"required": "Please enter a username"
}
}
// Example of the expected FormErrors shape
const errors: FormErrors = {
username: 'Required field',
address: {
street: 'The value must be a string'
},
items: [
{ name: 'Error in first item' }
]
};