Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using the new validation business map
The possible return values of custom validation function is only true or false.

The validation system uses the Valitron library:

This library takes a set of values, then a set of rules, and it applies all the rules to the values in one shot returning an array of all the rules that did not pass. Actually an error message for each rule that did not pass.

This looks like this:

PHP Code:
$v = new cbValidator($screen_values);
$v->rule('required', ['name''email']);

after that last line, $v contains the result of all the rules it has applied.

A custom validation must have a rule name and a function, so the example in the documentation would be called like this:

PHP Code:

note how I have given my validate_testacccemail() function a rule name. Valitron knows that when it has to apply the "testemail" rule, it must call the validate_testacccemail() function and it expects a true or false value to know if the field passes or not the rule.

Finally, in the result of the validations it will return a string which is the label of the field (Email in this case) followed by the rule that did not pass. For example,

Email is required

In coreBOS validations you can give an additional parameter to the custom validation rule which will be the text that appears after the field label. If none is given it simply outputs "Invalid"

Keep asking and let me know how it goes.

Messages In This Thread
RE: Using the new validation business map - joebordes - 11-07-2017, 06:42 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)