how to make password mask in ant design

Viewed 319

I have a task, I need to make a password mask for registration.

<Form.Item
    name='password'
    label='Password'
    rules={[
      {required: true, message: 'Please input your password!'},
      {
        validate: (_, value) => {
          console.log(111)
          if (/(?=.*[0-9])(?=.*[!@#$%^&*])(?=.*[a-z])(?=.*[A-Z])[0-9!*+%-<>@[]{}_#a-zA-Z]{6,}/g.test(value)) {
            return Promise.resolve()
          }
          return Promise.reject('The password must contain at least 8 characters (Latin letters, numbers and at least one character: ! * + % - < > @ [ ] { } _ #)')
        }
      }
    ]}
  >
    <Input.Password/>
  </Form.Item>

i did validate, but it doesn't work, i looked at examples, and it seems like i did an analog, but why doesn't it work...

1 Answers

The actual property for supplying a custom validation function for a rule is validator.

Change

validate: (_, value) => {

to:

validator: (_, value) => {
Related