I am new to ReactJs, I am Using Ant-design
For Registration Form and applied some validation Rules. I want to validate User when user enter something in fields, message ( Username must be Unique )
is shown to the user for guidance . But when I enter something Error is occur Unknown rule type username
.
Code of Form
<FormItem>
{getFieldDecorator('username', {
rules: [
{
type: 'username',
message: 'Username Must be Unique!',
},
{
required: true,
message: 'Please Enter Your Username',
},
],
})(<Input placeholder="Username" />)}
</FormItem>
You must be confusing type
with something else.
According to this page: https://ant.design/components/form/ , type will rather be referenced to something like string
or boolean
.
EDIT:
...
{
type: string,
message: 'Username Must be a string',
},
...