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

Issue fork drupal-3533926

Command icon 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

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems like a straight forward move. LGTM

  • catch committed 89abd7a0 on 11.x
    Issue #3533926 by alexpott: Config of the type plural_label can never be...
catch’s picture

Status: Reviewed & tested by the community » Fixed

This 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.

alexpott’s picture

Version: 11.x-dev » 11.2.x-dev
Status: Fixed » Reviewed & tested by the community

This is a bug and it'd help config validation if it was backported.

  • catch committed b3e05b6f on 11.2.x
    Issue #3533926 by alexpott: Config of the type plural_label can never be...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Cherry-picked to 11.2.x, 10.6.x and 10.5.x too.

  • catch committed 493d4497 on 10.5.x
    Issue #3533926 by alexpott: Config of the type plural_label can never be...

  • catch committed d1ba88ce on 10.6.x
    Issue #3533926 by alexpott: Config of the type plural_label can never be...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

claudiu.cristea’s picture