Drupal 8's Entity Validation API

In Drupal 8 Entity validation is decoupled from form API. This decoupling allows validation entities to be independent from form submissions, such as when changed via the RESTful web service or saving through a custom code. This new validation API has been implemented based on the Symfony validator.
The session will cover following points:
  • Using API to validate entities: Calling validate() on entity.
  • Putting constraints on field item properties: Attach your validation constraints to your entity types and fields - How and where?
  • A custom validation constraint - How to create own constraint plugin to validate an entity?
  • Relationship to Symfony validator: Drupal makes use of Symfony constraint classes and their validation logic (ConstraintValidator classes). As with every other plugin in Drupal 8, each constraint plugin defines its ID in its annotation.

Session Track

Coding and Development

Experience Level


Drupal Version