Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant design form async-validator warning

Tags:

reactjs

antd

I am using antd forms and rules and when im submiting a form i get warnings like:

async-validator: ["Please enter username"].

I tried { suppressWarning: true } but it didn't work, the warning is not the same text in the rule its the default template text

antd: ^4.6.4

 <Form
      {...layout}
      name="basic"
      initialValues={{
        remember: true,
      }}
      onFinish={onFinish}
      onFinishFailed={onFinishFailed}
    >
      <Form.Item
        label="Username"
        name="username"
        rules={[
          {
            required: true,
            message: 'Please input your username!',
          },
        ]}
      >
        <Input />
      </Form.Item>

      <Form.Item
        label="Password"
        name="password"
        rules={[
          {
            required: true,
            message: 'Please input your password!',
          },
        ]}
      >
        <Input.Password />
      </Form.Item>

      <Form.Item {...tailLayout} name="remember" valuePropName="checked">
        <Checkbox>Remember me</Checkbox>
      </Form.Item>

      <Form.Item {...tailLayout}>
        <Button type="primary" htmlType="submit">
          Submit
        </Button>
      </Form.Item>
    </Form>
like image 270
lebelo4747 Avatar asked Nov 16 '22 04:11

lebelo4747


1 Answers

As described on the async-validator page (https://github.com/yiminghe/async-validator)

At the entry point to your app you can do the following to disable the warning messages.

import Schema from 'async-validator';
Schema.warning = function(){};
like image 139
Cian Montgomery Avatar answered Dec 19 '22 16:12

Cian Montgomery