Validation 

Configure validators per column to enforce data integrity on write operations.

Validator types 

Type Parameters Description
required (none) Enforced via the required column key. The field must be present and non-empty on POST/PUT. Skipped on PATCH if the field is absent.
maxLength max (int) Maximum string length.
minLength min (int) Minimum string length.
regex pattern (string) PCRE pattern the value must match.

Configuration 

'columns' => [
    'title' => [
        'groups'     => ['list', 'show', 'create', 'update'],
        'required'   => true,
        'validators' => [
            ['type' => 'maxLength', 'max' => 255],
            ['type' => 'minLength', 'min' => 3],
            ['type' => 'regex', 'pattern' => '/^[\w\s]+$/u'],
        ],
    ],
],
Copied!

Error response 

Validation failures return 422 Unprocessable Entity with a Hydra-compatible error response:

{
    "@context": "http://www.w3.org/ns/hydra/context.jsonld",
    "@type": "hydra:Error",
    "hydra:title": "Validation Failed",
    "hydra:description": "1 validation error(s)",
    "violations": [
        {
            "propertyPath": "title",
            "message": "Field 'title' is required.",
            "code": "REQUIRED"
        }
    ]
}
Copied!

PATCH behaviour 

On PATCH requests (partial updates), the required check is skipped for fields that are not present in the request body. Only the submitted fields are validated.