Add validation constraints to user.mail

Created on 3 July 2024, 6 months ago
Updated 31 July 2024, 5 months ago

Problem/Motivation

user.mail is fully validatable

./vendor/bin/drush config:inspect --filter-keys=user.mail --detail --list-constraints  --fields=key,validatability,constraints
➜  🤖 Analyzing…

 ---------------------------------------------------- ------------- ---------------------------------------------------------
  Key                                                  Validatable   Validation constraints
 ---------------------------------------------------- ------------- ---------------------------------------------------------
  user.mail                                            100%          ValidKeys: '<infer>'
                                                                     LangcodeRequiredIfTranslatableValues: null
   user.mail:                                          Validatable   ValidKeys: '<infer>'
                                                                     LangcodeRequiredIfTranslatableValues: null
   user.mail:_core                                     Validatable   ValidKeys:
                                                                       - default_config_hash
   user.mail:_core.default_config_hash                 Validatable   NotNull: {  }
                                                                     Regex: '/^[a-zA-Z0-9\-_]+$/'
                                                                     Length: 43
                                                                     ↣ PrimitiveType: {  }
   user.mail:cancel_confirm                            Validatable   ValidKeys: '<infer>'
   user.mail:cancel_confirm.body                       Validatable   Regex:
                                                                       pattern: '/([^\PC\x09\x0a\x0d])/u'
                                                                       match: false
                                                                       message: 'Text is not allowed to contain control
                                                                     characters, only visible characters.'
                                                                     ↣ PrimitiveType: {  }
   user.mail:cancel_confirm.subject                    Validatable   Regex:
                                                                       pattern: '/([^\PC])/u'
                                                                       match: false
                                                                       message: 'Labels are not allowed to span multiple
                                                                     lines or contain control characters.'
                                                                     NotBlank: {  }
                                                                     ↣ PrimitiveType: {  }
   user.mail:langcode                                  Validatable   NotNull: {  }
                                                                     Choice:
                                                                       callback:
                                                                     'Drupal\Core\TypedData\Plugin\DataType\LanguageReferenc
                                                                     e::getAllValidLangcodes'
                                                                     ↣ PrimitiveType: {  }
   user.mail:password_reset                            Validatable   ValidKeys: '<infer>'
   user.mail:password_reset.body                       Validatable   Regex:
                                                                       pattern: '/([^\PC\x09\x0a\x0d])/u'
                                                                       match: false
                                                                       message: 'Text is not allowed to contain control
                                                                     characters, only visible characters.'
                                                                     ↣ PrimitiveType: {  }
   user.mail:password_reset.subject                    Validatable   Regex:
                                                                       pattern: '/([^\PC])/u'
                                                                       match: false
                                                                       message: 'Labels are not allowed to span multiple
                                                                     lines or contain control characters.'
                                                                     NotBlank: {  }
                                                                     ↣ PrimitiveType: {  }
   user.mail:register_admin_created                    Validatable   ValidKeys: '<infer>'
   user.mail:register_admin_created.body               Validatable   Regex:
                                                                       pattern: '/([^\PC\x09\x0a\x0d])/u'
                                                                       match: false
                                                                       message: 'Text is not allowed to contain control
                                                                     characters, only visible characters.'
                                                                     ↣ PrimitiveType: {  }
   user.mail:register_admin_created.subject            Validatable   Regex:
                                                                       pattern: '/([^\PC])/u'
                                                                       match: false
                                                                       message: 'Labels are not allowed to span multiple
                                                                     lines or contain control characters.'
                                                                     NotBlank: {  }
                                                                     ↣ PrimitiveType: {  }
   user.mail:register_no_approval_required             Validatable   ValidKeys: '<infer>'
   user.mail:register_no_approval_required.body        Validatable   Regex:
                                                                       pattern: '/([^\PC\x09\x0a\x0d])/u'
                                                                       match: false
                                                                       message: 'Text is not allowed to contain control
                                                                     characters, only visible characters.'
                                                                     ↣ PrimitiveType: {  }
   user.mail:register_no_approval_required.subject     Validatable   Regex:
                                                                       pattern: '/([^\PC])/u'
                                                                       match: false
                                                                       message: 'Labels are not allowed to span multiple
                                                                     lines or contain control characters.'
                                                                     NotBlank: {  }
                                                                     ↣ PrimitiveType: {  }
   user.mail:register_pending_approval                 Validatable   ValidKeys: '<infer>'
   user.mail:register_pending_approval.body            Validatable   Regex:
                                                                       pattern: '/([^\PC\x09\x0a\x0d])/u'
                                                                       match: false
                                                                       message: 'Text is not allowed to contain control
                                                                     characters, only visible characters.'
                                                                     ↣ PrimitiveType: {  }
   user.mail:register_pending_approval.subject         Validatable   Regex:
                                                                       pattern: '/([^\PC])/u'
                                                                       match: false
                                                                       message: 'Labels are not allowed to span multiple
                                                                     lines or contain control characters.'
                                                                     NotBlank: {  }
                                                                     ↣ PrimitiveType: {  }
   user.mail:register_pending_approval_admin           Validatable   ValidKeys: '<infer>'
   user.mail:register_pending_approval_admin.body      Validatable   Regex:
                                                                       pattern: '/([^\PC\x09\x0a\x0d])/u'
                                                                       match: false
                                                                       message: 'Text is not allowed to contain control
                                                                     characters, only visible characters.'
                                                                     ↣ PrimitiveType: {  }
   user.mail:register_pending_approval_admin.subject   Validatable   Regex:
                                                                       pattern: '/([^\PC])/u'
                                                                       match: false
                                                                       message: 'Labels are not allowed to span multiple
                                                                     lines or contain control characters.'
                                                                     NotBlank: {  }
                                                                     ↣ PrimitiveType: {  }
   user.mail:status_activated                          Validatable   ValidKeys: '<infer>'
   user.mail:status_activated.body                     Validatable   Regex:
                                                                       pattern: '/([^\PC\x09\x0a\x0d])/u'
                                                                       match: false
                                                                       message: 'Text is not allowed to contain control
                                                                     characters, only visible characters.'
                                                                     ↣ PrimitiveType: {  }
   user.mail:status_activated.subject                  Validatable   Regex:
                                                                       pattern: '/([^\PC])/u'
                                                                       match: false
                                                                       message: 'Labels are not allowed to span multiple
                                                                     lines or contain control characters.'
                                                                     NotBlank: {  }
                                                                     ↣ PrimitiveType: {  }
   user.mail:status_blocked                            Validatable   ValidKeys: '<infer>'
   user.mail:status_blocked.body                       Validatable   Regex:
                                                                       pattern: '/([^\PC\x09\x0a\x0d])/u'
                                                                       match: false
                                                                       message: 'Text is not allowed to contain control
                                                                     characters, only visible characters.'
                                                                     ↣ PrimitiveType: {  }
   user.mail:status_blocked.subject                    Validatable   Regex:
                                                                       pattern: '/([^\PC])/u'
                                                                       match: false
                                                                       message: 'Labels are not allowed to span multiple
                                                                     lines or contain control characters.'
                                                                     NotBlank: {  }
                                                                     ↣ PrimitiveType: {  }
   user.mail:status_canceled                           Validatable   ValidKeys: '<infer>'
   user.mail:status_canceled.body                      Validatable   Regex:
                                                                       pattern: '/([^\PC\x09\x0a\x0d])/u'
                                                                       match: false
                                                                       message: 'Text is not allowed to contain control
                                                                     characters, only visible characters.'
                                                                     ↣ PrimitiveType: {  }
   user.mail:status_canceled.subject                   Validatable   Regex:
                                                                       pattern: '/([^\PC])/u'
                                                                       match: false
                                                                       message: 'Labels are not allowed to span multiple
                                                                     lines or contain control characters.'
                                                                     NotBlank: {  }
                                                                     ↣ PrimitiveType: {  }
 ---------------------------------------------------- ------------- ---------------------------------------------------------

Steps to reproduce

  1. Get a local git clone of Drupal core 11.x.
  2. composer require drupal/config_inspector — or manually install https://www.drupal.org/project/config_inspector/releases/2.1.5 → or newer (which supports Drupal 11!)
  3. composer require drush/drush
  4. vendor/bin/drush config:inspect --filter-keys=user.mail --detail --list-constraints

Proposed resolution

Add validation constraints to:

  1. user.mail

Remaining tasks

None

User interface changes

None.

API changes

None.

Data model changes

More validation 🚀

Release notes snippet

None.

📌 Task
Status

Fixed

Version

11.0 🔥

Component
Configuration  →

Last updated 2 days ago

Created by

🇮🇳India yash.rode pune

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024