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_only": ?Boolean,
    "numeric": ?Boolean, /* deprecated */
    "letters_uppercase": ?Boolean, /* deprecated */
    "letters_lowercase": ?Boolean, /* deprecated */
    "symbols": ?Boolean, /* deprecated */
    "char_blacklist": ?Boolean,
    "pattern": ?Boolean,
    "allow_selected_min": ?Boolean,
    "allow_selected_max": ?Boolean,
    "option_disabled": ?Boolean,
    "valid_options": ?Boolean
}

type Boolean, optional

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<Integer> but received a string instead).

Handling Validation Errors

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

Notable Cases

The max_value & min_value Errors

The max_value and min_value errors apply for the Padlock and the Input element.

For the padlock element 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.

For the input element the max_value and/or min_value validation error is returned if the specified max_value and/or min_value properties of the input element have been disregarded.

The allow_selected_max & allow_selected_min Errors

The allow_selected_max and allow_selected_min apply for the Choice element.

The errors will be set to true if the allow_selected.min and/or allow_selected.max attribute of the element have been disregarded.

Disabled Options

The option_disabled error applies for the elements Choice and Switchable.

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

Invalid Options

The valid_options error applies for the elements Choice and Switchable.

A valid_options validation error is returned if the selected option is not one of the choosable options.

Example

Description Example
Single validation error

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

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

results matching ""

    No results matching ""