In ant design one can provide a custom validator like the following:
<Form.Item label=First Name>
{getFieldDecorator(firstName, {
rules: [
{
validator: (rule: any, value: string, cb: (msg?: string) => void) => {
value.length < 3 ? cb(too short) : cb();
}
}
]
})(<Input />)}
</Form.Item>
As you see I'm using typescript and cause its transpiler is really cool it wants me to use rule
parameter of validator
as well. I can't find any documentation on it and don't know what is good for. So if you can please explain briefly what is it and how it should be used?