Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Implement basic validation depending on the property type, e.g. support a regex key in the definition for strings or max/min for integers.
Comments
Comment #1
fmizzell CreditAttribution: fmizzell commentedI wonder if it could be worth it to make validation configurable and extendable (each property instance can request different types of validation that it wants to use, and modules can define manners in which to validate different data types). So instead of hard coding the types of validation allowed for each data type in their validate() method, validate() can become part of the base class and it can call whatever validation code we are asking for in the definition (or configuration) of a property instance. I hope that makes sense.
Comment #2
fagoYep, we definitely want to support custom validation logic. Still, some basic per-type validation helps to easily support basic validation without having to implement this simple logic repeatedly. e.g. this could be the definition for an integer:
Comment #3
fagoThat's solved with #1845546: Implement validation for the TypedData API :-)