Problem/Motivation
Surfaced at #3397493: Add validation constraints to block_content.type.*, specifically at https://git.drupalcode.org/project/drupal/-/merge_requests/5170/diffs#no...
#3404061: When setting `NotNull` constraint on type: required_label, two validation errors appear improved the DX for using NotBlank in the "required value" case.
But turns out that in the "optional value" case, we can improve it too!
Steps to reproduce
Proposed resolution
Always set $constraints['NotBlank']['allowNull'] = TRUE; because:
- when it is required (i.e.
nullable: false, which is the default),nullwill trigger theNotNullconstraint, andNotBlankshould not generate an equivalent message again - when it is optional (i.e.
nullable: true, which must be explicitly specified), thennullis a valid value andNotBlankshould not complain
Remaining tasks
- ✅ Tweak the infrastructure.
- ✅ Prove the DX impact by simplifying
node.schema.yml.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.
Issue fork drupal-3413144
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
wim leersComment #4
wim leersThis relates to #3364109: Configuration schema & required values: add test coverage for `nullable: true` validation support and so I linked this issue from the change record from that cluster of issues: https://www.drupal.org/node/3404425
Comment #5
wim leersComment #6
phenaproximaComment #7
wim leers