Forums

Validate Data action and settings

It's been asked before but never properly answered : what are the available options in the Validate Data action? After browsing through the code, here you are.

NOTE: Rules that require a parameter in square brackets require version 6.0.22 or higher.

HOW TO USE:
fieldname/rule:Message if the validation fails
or
fieldname/rule[parameter]:Message if the validation fails

is_integer : Checks if the value is positive or negative whole number e.g. 123 or -123
decimal : Positive or negative number with REQUIRED decimal point, e.g. 123.45
number : Positive or negative number with OPTIONAL decimal point e.g. 123 or 123.45
match[value] : Does the field match the value? Uses == not ===
different[value] : Is the field NOT equal to the value? Uses != not !==
regex[pattern] : Does the field match the regex pattern? E.g. text/regex[/#^\d{4}$#/]:regex failed! Will show "regex failed!" if the user doesn't enter 4 digits into the 'text' field
contains[value] : Does the field CONTAIN the value? Case insensitive
containsExactly[value] : Does the field contain the value? Case sensitive (capitalisation has to match)
doesntContain[value] : Self explanatory surely? Case insensitive
doesntContainExactly[value] : Same, but case sensitive
minLength[x] : Has to have at least x characters
exactLength[x]
maxLength[x]
minCount[x] : For arrays or selections, e.g. did they select at least X options?
exactCount[x]
maxCount[x]
alpha : Letters only
alphanumeric : Letters and numbers only
nodigit : I assume it means no numbers? The regex is /^[^0-9]+$/
phone : Don't know what country this phone pattern is for. /^\+{0,1}[0-9 \(\)\.\-]+$/
phone_inter : I assume this is for international numbers of some sort. /^\+{0,1}[0-9 \(\)\.\-]+$/
gix.vax 17 Oct, 2019
hi
i'm trying to use validation fields with regex in my field "conferma_password" (a confirm password field)
i want a password that have at least : 1 uppercase, 1 lowercase, 1 number, min 8 and max 15 characters

field conferma_password
in regex i put
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z0-9]{8,15}$/

in Matches i put "password" (without quotes) that is the name of the other field that must match.

in validation rules i put
conferma_password/regex[/^(?=.*[A-Z])[a-zA-Z0-9]{8,15}$/]:almeno una lettera maiuscola (no uppercase)
conferma_password/regex[/^(?=.*[a-z])[a-zA-Z0-9]{8,15}$/]:almeno una lettera minuscola (no lowercase)
conferma_password/regex[/^(?=.*\d)[a-zA-Z0-9]{8,15}$/]:almeno un numero (no numbers)
conferma_password/minLength[8]:minimo 8 caratteri (min 8 char)
conferma_password/maxLength[15]:massimo 15 caratteri (max 15 char)

Everytime it displays the first error message (tried changing position of the messages but it display the first in any case)
i've tried to put the "not" using the ! in this way
conferma_password/regex[/^(?!.*[A-Z])[a-zA-Z0-9]{8,15}$/]:almeno una lettera maiuscola (no uppercase)
but nothing
i tested regex online and the regex field and the validation rules are correct

where i fail?

thank you
healyhatman 18 Oct, 2019
I don't think you can have the same rule multiple times for the same field buddy. And even if you could, I don't think combining 3 regexs is the way to go, surely?
gix.vax 18 Oct, 2019
If i put only the regex in the regex field it works ok, but in this way i can't show different messages for every portion of the regex (uppercase error, lowercase error etc.)

If i can't use more regex in the validation rules field, i'm chained to the rules defined (contains, containsexactly etc.)
The regex give the flexibilty i need.

Is there a way to use it one per row in validation rules field?
Or better is there a way to combine, for example, containexactly with regex syntax?
confirm_password/containsExactly[regex[/^(?=.*[A-Z])[a-zA-Z0-9]{8,15}$/]]:no uppercase character foundconfirm_password/

or this?
confirm_password/containsExactly[A-Z]:no uppercase character found
healyhatman 18 Oct, 2019
Just do it in PHP man that's all too complicated. Return a message if there's a problem, then check if the {var:phpblockname} is not empty and display the message.
gix.vax 18 Oct, 2019
OK but i want it in real time:
when the user digit i want to show what are the needings remaining to be a password validated, in this way:

if he type an "A" i give a message (tooltip?) that say "1 lower case needed, 1 number neeeded, min 8 max 15"
if he type "Ab" i give a message that say "1 number neeeded, min 8 max 15"
and so on checking all the conditions

i think i need a function in JavaScript that send back a message that is the sum of errors
now, i think i have to use the field Event!!???!!??
TAB Events -> Triggering event : Change
TAB Events -> Triggered actions : function
Possible values, one per line : the name of the function block in javascript ???????????
Affected elements CSS selectors, example: #id, name, .class ????????????????????
healyhatman 18 Oct, 2019
Javascript then. Multiple functions. Check faq
This topic is locked and no more replies can be posted.