ionic-team / ionic-team/ionic-framework
feat: insufficient validation for correct email in IonInput
- 主要语言
- TypeScript
- 星标
- 52.7k
- 派生
- 13.3k
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 51
描述
### Prerequisites
- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already include this feature request, without success.
### Describe the Feature Request
A validator for email that better checks if an email corresponds to basic requirements for an email.
### Describe the Use Case
Currently is considered correct by the IonInput validator for email:
[alphanumeric chars]@[alphanumeric chars] (like 1@1 or a@a or a1@1a)
[alphanumeric chars]@[alphanumeric chars].oneAlphanumericChars (like 1@1.a or a@1.1).
But an email must be based on a domain name which means it should end with a dot and a top-level domains (like .com, .tv, .berlin).
So to be validated an email should have:
1. a dot after the sequence [alphanumeric chars]@[alphanumeric chars]
2. then more than one alpha chars AND no numbers (TLDs haven't any numbers)
### Describe Preferred Solution
There is actually a norm than define correct email: https://www.rfc-editor.org/rfc/rfc2822#section-3.4.1 .
2 Regex can help:
- the simple one: /[^\s@]+@[^\s@]+\.[^\s@]+/
- the "RFC 2822: /(?:[a-z0-9+!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/i
### Describe Alternatives
_No response_
### Related Code
_No response_
### Additional Information
_No response_
贡献指南
评估
这个 Issue 还没有评估数据。