forms icon indicating copy to clipboard operation
forms copied to clipboard

Is it possible to create custom validators ? and create validator for, eg, two fields ?

Open julestruong opened this issue 9 years ago • 2 comments

julestruong avatar Mar 31 '16 13:03 julestruong

never mind i found how :

validators: [(form, field, callback) => {
                if (field.data !== "ok") {
                    callback("msg error");
                } else {
                    callback();
                }
            }]

U may want to add this in documentation :)

but still i would love to know how to combine validations for a whole form

julestruong avatar Mar 31 '16 14:03 julestruong

A PR to improve the documentation is always welcome!

Validations are performed per-field - you can certainly reuse a validator on as many fields as you like by storing the function in a variable, and passing that variable into multiple fields.

ljharb avatar Mar 31 '16 16:03 ljharb