I have a form where each field has several rule validations. The "custom rule" option available on each field comes in handy, but with several rules becomes unreadable and unmantainable.
There is any way to use the JavaScript output in "custom rule"?
Script example:
if(field1.value.length < 3) {
return { valid: false, message: "Too short..." };
} else if (field1.value.length > 10) {
return { valid: false, message: "Too long" };
} else {
return { valid: true, message ""};
}
I know that this example can be simplified, but for the sake of the scenario I intend to illustrate, bear with me.
My goal is to achieve something like:
{{ !jsQuery.data.valid ? jsQuery.data.message : ''}}
BTW, I tried this with a transformer, but it just doesn't recognize the fields (although they are recognized everywhere else).