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.
Updated: Comment #14
Problem/Motivation
StringItem's have a 'maxlength'. This maxlength is not enforced by typed data validation constraint, however.
Proposed resolution
Automatically add a validation constraint based on the 'maxlength' setting.
Remaining tasks
Make tests pass.
User interface changes
None.
API changes
An additional validation constraint for StringItem's with a maxlength.
Comment | File | Size | Author |
---|---|---|---|
#14 | 2181461-14-string-maxlength-validation.patch | 1.47 KB | tstoeckler |
Comments
Comment #1
tstoecklerHere we go.
Comment #2
tstoecklerComment #3
tstoecklerPer @dawehner adding the missing newline at the end of the class.
Comment #4
dawehnerPerfect, now we are in sync with the Constraint in the annotation.
Comment #5
tstoecklerComment #6
alexpottThis change looks like this could be done by adding the following to the annotation:
See
\Drupal\Core\Entity\Plugin\Field\FieldType\StringItem
Comment #7
tstoecklerThat's true, but then let's also automate the maxlength constraint.
For the extra nitpicky: I removed an unused use statement in UuidItem after generating the interdiff, sorry for that.
Comment #9
Berdir7: 2181461-7-uuid-maxlength-schema.patch queued for re-testing.
Comment #11
andypostFaced with the same trouble in #2150511: [meta] Deduplicate the set of available field types
Can't find the place where this kind of annotation is parsed
Comment #12
andypostMostly all test failures caused by that all testing code checks explicit error message that vary depending on the constraint definition
Comment #13
andypostThe solution in #2002168: Convert form validation of terms to entity validation
Suppose better to limit scope by #3
Comment #14
tstoecklerThis needed a re-roll. So here it is. The UuidItem annotation got updated in the meantime, so this just adds the validation constraint based on maxlength.
I also think it makes sense to split this from #2150511: [meta] Deduplicate the set of available field types. That issue has a much broader scope while it seems making the tests pass here will be non-trivial already.
I'm updating the title and issue summary for that.
Comment #15
tstoecklerComment #17
tstoecklerHuh, that's awesome. The exact same code was added already in #2002168: Convert form validation of terms to entity validation. So this is already fixed in HEAD. Thanks @klausi and @effulgentsia!!!