Open
Description
Which @angular/* package(s) are relevant/related to the feature request?
No response
Description
This topic has been discussed multiple times (#16544, #26395, #32788): Angular’s built-in Validators.email
is intentionally permissive (accepts emails like a@a
). Many developers find it insufficient for stricter email-validation needs in production apps.
Proposed solution
Introduce an injectable token (EMAIL_VALIDATOR_PATTERN
) to allow globally setting a custom regex pattern for email validation, configured once in main.ts
:
// main.ts
providers: [
{ provide: EMAIL_VALIDATOR_PATTERN, useValue: /^[^@\s]+@[^@\s]+\.[^@\s]{2,}$/ }
]
If provided, Angular's built-in Validators.email
would automatically use this custom pattern.
Alternatives considered
The current workaround is creating custom validators individually in each form or field, resulting in repetitive and error-prone implementations across applications.