Skip to main content Link Menu Expand (external link) Document Search Copy Copied


There are different approaches to validate your application’s incoming data.

Form and JSON validation

This project comes with cakephp/validation + selective/validation and contains some usage examples.

The cakephp/validation component is needed to validate complex form data (arrays) against a specific set of rules, and the selective/validation component collects the validation errors, throws validation exceptions and transforms the result into a proper JSON response.

Read more

OpenAPI validation

The league/openapi-psr7-validator package can validate PSR-7 messages against OpenAPI (3.0.x) specifications expressed in YAML or JSON.

The justinrainbow/json-schema package is for validating JSON structures against a given schema.

JSON schema validation

The league/json-guard package lets you validate JSON data using json schema.

XML validation

The DOMDocument::schemaValidate method is able to validate XML files against a XSD schema.


The webmozart/assert and beberlei/assert package provides assertions to validate method input/output with nice error messages.