I understand that when we create a form using Ant Design, we can code it like:<Form.Item name={['user', 'email']} label="Email" rules={[{ type: 'email' }]}>
However, I can not find the way of how Ant Design validate it or using which regular expression as the pattern.
Do you know where should I get the reference from? I have checked the Rule API, but can not find it.
Antd uses rc-field-form
and this form package uses async-validator for validation.
The regex for email is as follow:
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
You can check the source code here.