Decoupling Entity-validations from Entity-forms

Entities are an integral part of the Drupal ecosystem and almost every entity in Drupal is linked with forms. Thus Drupal provides a beautiful Form API that helps in building, validating and submission of forms. All three stages are very important and have their own significance. But our focus throughout the session will be the form validation aspect.

To perform custom server-side validations on forms we often write #validate functions in Drupal which always do the job. But there are some negatives to it, Example: Validations don’t run when you try creating/editing the entity via means other than entity form. Perhaps this problem was assessed and tackled in Drupal 8 by the introduction of Entity validation constraints.

In this session we will be learning about the following:
- Problem with form API validation
- Creating custom validation constraint
- Applying validation constraint to the entity field
- Applying validation constraint to the entity
- Running validations on Entity Forms
- Running validations on REST API requests
- Running validations on custom routes
- The Demo

At the end of this session, users will have a clear understanding of how decoupling entity validation from entity forms allows validations to be independent of form submissions.

Share This Page