25th September 2022 - 14 minutes read time
Client requirements can be complex and those complex requirements often require custom code to be written. This includes making sure that the editing process conforms to certain validations.
Drupal can easily handle simple validation like having a value in the field or making sure an email is valid, but with more complex validations usually require custom code.
Whilst it is possible to inject custom validators into form submissions, I find using validation constraint classes makes the whole process much more predicable. Also, validation constraints are applied at a lower level than form validations, which means we can validate the data is correct even if we are creating the entity from an API.