Open FiloSpaTeam opened 9 years ago
Ok, i've done a good modification over this library.
Example of JSON rules:
function rules() {
return {
"login" : {
"nome" : {
"input" : inputEmail,
"type" : "TextField",
"rules" : ["required", "email"]
},
"password" : {
"input" : inputPassword,
"type" : "TextField",
"rules" : ["required", "min:8", "max:16"]
}
},
"registrati" : {
"nome" : {
"input" : inputNome,
"type" : "TextField",
"rules" : ["required", "regexp:^[A-Za-z]+$", "min:2"]
},
"email" : {
"input" : inputEmail,
"type" : "TextField",
"rules" : ["required", "email"]
},
"password" : {
"input" : inputPassword,
"type" : "TextField",
"rules" : ["required", "min:8", "max:16"]
},
"password_confirmation" : {
"input" : inputConfermaPassword,
"type" : "TextField",
"rules" : ["required", "min:8", "max:16", "confirmation:" + inputPassword.text]
}
}
}
}
Example of signal use (TextField):
onTextChanged: ErrorValidator.checkTextField(rules[base.state]["email"])
Example of global check (example on confirm click):
if (ErrorValidator.check(rules, base.state))
// VALID CODE
Can you provide source of rule.js please
if can be usefull i've implemented a stateless library that can be used to validate real time, manually, every x time, an object and use appropriate error of that.
Example of code:
NoError:
Error1:
Error2:
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.