Server-side Validation

As the client can not be trusted to validate all the data correctly, there will be server-side checks for the validity of the received value(s).

If such a validation fails, the form is sent back to the client with additional validation error information.

Structure

Each element that can hold a validator property can also have a validation_error property. Additionally the choice element can have a validation_error in the allow_selected property.

The validation_error property is an object holding the rule name as a key (e.g. min_length). The value corresponding to the key is a boolean which indicates whether or not the validation rule has been broken. Most of the time unbroken validation rules will not be present in the validation_error object.

{
    "type": ?boolean,
    "min_length": ?boolean,
    "max_length": ?boolean,
    "required": ?boolean,
    "min_value": ?boolean,
    "max_value": ?boolean,
    "numeric": ?boolean,
    "letters_uppercase": ?boolean,
    "letters_lowercase": ?boolean,
    "symbols": ?boolean,
    "char_blacklist": ?boolean,
    "pattern": ?boolean,
    "allow_selected.min": ?boolean,
    "allow_selected.max": ?boolean
}

The type Validation Error

If the type attribute is set to true the result value sent to the server did not match the format that was expected (e.g. the server expected an array<number> but received a string instead).

Handling Validation Errors

It is recommended to show a suitable error message when a validation rule has been broken.

Special Cases

Padlock

A max_value validation error is returned if the server finds a value inside the numbers array which is greater than (padlock.rows * padock.columns) -1.

A min_value validation error is returned if the server finds a value inside the numbers array which is lower than 0.

Disabled Options

An option_disabled validation error is returned if the server finds a selected option which is marked as disabled.

Example

Description Example
Single validation error

Value was empty (required)
{
    "required": "true",
}
Multiple validation errors

Value was to short (min_length)
Value did not match the pattern (pattern)
{
    "min_length": "true",
    "pattern": "true",
}

results matching ""

    No results matching ""