Problem/Motivation
Consider
label:
type: string
label: 'Optional label'
translatable: true
constraints:
Regex:
# Forbid any kind of control character.
# @see https://stackoverflow.com/a/66587087
pattern: '/([^\PC])/u'
match: false
message: 'Labels are not allowed to span multiple lines or contain control characters.'
But
# String containing plural variants, separated by EXT.
plural_label:
type: label
label: 'Plural variants'
And then in views...
format_plural_string:
type: plural_label
label: 'Plural variants'
constraints:
Regex:
# Normally, labels cannot contain invisible control characters. In this particular
# case, an invisible character (ASCII 3, 0x03) is used to encode translation
# information, so carve out an exception for that only.
# @see \Drupal\views\Plugin\views\field\NumericField
pattern: '/([^\PC\x03])/u'
match: false
message: 'Labels are not allowed to span multiple lines or contain control characters.'
Steps to reproduce
Proposed resolution
Move the constraint from views to core.
Remaining tasks
User interface changes
None
Introduced terminology
N/a
API changes
None
Data model changes
None
Release notes snippet
N/a
Comments
Comment #3
alexpottComment #4
smustgrave commentedSeems like a straight forward move. LGTM
Comment #6
catchThis looks good.
Committed/pushed to 11.x, thanks!
I'm unsure about 11.2 and 10.6/5 backports to moving to fixed against 11.x, re-open if you feel strongly it should be backported.
Comment #8
alexpottThis is a bug and it'd help config validation if it was backported.
Comment #10
catchCherry-picked to 11.2.x, 10.6.x and 10.5.x too.
Comment #14
claudiu.cristeaThis is a duplicate of #3409588: Test validation constraint to type: plural_label in core.data_types.schema which had also tests. #3409588: Test validation constraint to type: plural_label in core.data_types.schema has been rescoped to provide test coverage for this change