Problem/Motivation
The Email typed-data class declares format: email
on getCastedValue(). Drupal's Email constraint accepts
empty strings and supports international email addresses. Schema
validators enforcing the email format can reject values accepted
by Drupal validation.
This existing mismatch was identified while reviewing
#3627330.
The reviewer requested a separate follow-up because the attribute
already exists on main.
Steps to reproduce
- Create an email data definition and its typed-data object.
- Compare Drupal validation of an empty string and international
email addresses with the generated JSON Schema. - Observe that the schema includes
format: email.
Check acceptance using a schema validator configured to assert
email formats.
Proposed resolution
Agree on a JSON Schema representation for the Email data type
that accommodates values accepted by Drupal validation. Add
regression coverage for empty strings, ordinary addresses,
international addresses, and optional null values.
Remaining tasks
- Confirm the mismatch with documented validator behavior.
- Agree on the schema representation.
- Implement the change and regression tests.
User interface changes
None proposed.
API changes
To be determined. Generated Email schemas may change.
Data model changes
None proposed.
Issue fork drupal-3643896
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
mukesh-kumar3 commentedPrepared a fix replacing
format: emailwith ananyOfcontaining an empty-string alternative andformat: idn-email.Added regression coverage for required and optional values, including empty strings, international local parts and domains, and optional null.
Local verification:
Separately verified six samples using Opis JSON Schema 2.6.3 with format assertions. The new schema accepts the empty and international samples and rejects the invalid-address sample. Drupal's bundled schema validator does not enforce
idn-email.Comment #4
mukesh-kumar3 commented