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.
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.
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.
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.