How can i validate the email but the input is not required field?

Viewed 36

How can i create a rule for when the user going to written down the email to check if is valid, but that field should not to be required, so far i can not see the error because is not required field

<Form.Item className="form-item" label={'label'} name="organization" rules={[
              {
                pattern: new RegExp(/^[a-zA-Z]*$/),
                message: 'No Numbers Allowed'
              },
            ]} >

its possible create a rule to a field not required?

1 Answers

Add this rule only. No need to add required field.

{
   pattern: new RegExp(/^[^\s@]+@[^\s@]+\.[^\s@]+$/),
   message: 'Not a valid email address'
},
Related