Email validation in React ant design form

Viewed 16113

I am working with ant design in React.js. I'm trying to validate email with ant design rules. My regex does not work.

<Form.Item>
    {getFieldDecorator('email', {
        initialValue:null,
        rules: [
            {
                required: false,
                pattern: new RegExp("/\S+@\S+\.\S+/"),
                message:
                    'Enter a valid email address!',
            },
        ],
    })(
        <Input
            className="form-control"
            type="text"
            placeholder="Email"
        />,
    )}
</Form.Item>
2 Answers
<Form.Item
    name="email"
    label="E-mail"
    rules={[
      {
        type: 'email',
        message: 'The input is not valid E-mail!',
      },
      {
        required: true,
        message: 'Please input your E-mail!',
      },
    ]}
  >
    <Input />
  </Form.Item>
Related