Decoupling Entity-Validations From Entity-Forms

kunalkursija

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 this session will be on the form validation aspect.

In Drupal, To perform custom server-side validations on forms we often use form-alter hooks and add #validate functions and they are almost adequate to take care of validations. But there are some negatives to it, Example: Such validations don’t run when you try creating/editing the entity via means other than entity form. Perhaps this problem was assessed and tackled by the introduction of Entity validation API.

In this session we will be learning about the following via a demo:
- Problem with form API validation
- Creating custom validation constraint
- Applying validation constraint to the entity field
- Applying validation constraint to the entities
- Running validations on Entity Forms
- Running validations on REST API requests
- Running validations on Custom Routes

This session will enable you to have a clear understanding of how the DRY principle can be enforced in the decoupling of validations from the entity forms.

Track

Development & Coding