Validation
Powerful validations for your forms and input elements.
CBWIRE includes powerful validations provided by cbValidation that you can use to validate your Properties.
Installation
You'll need to install cbValidation to use the validation features with CBWIRE.
To install cbValidation, run the following command in CommandBox:
Previous versions of CBWIRE included cbValidation automatically. However, this introduced issues if you wanted to use a module version different from CBWIRE's version, so you now must manually install cbValidation.
Defining Constraints
You can define constraints within your components by populating a constraints struct. Once constraints are defined, CBWIRE will automatically validate your component on each request.
Manual Validation
You can manually validate your component using the validate() or validateOrFail() methods.
validate
Returns a ValidateResult object.
validateOrFail
Silently fails and prevents further processing of the current action.
With validateOrFail(), the error is gracefully caught and any further processing of the invoked action is prevented. The XHR response and re-rendered template are still returned. The actual errors themselves are available to the template using the validation variable.
If you need more granular control over the response, use validate() instead.
Explicit Constraints
If you can also run validations against any constraints you provide by passing them to the validate() method.
Displaying Errors
You can access the ValidationResults object using the validation variable. This includes helpful methods you can use for displaying error messages.
Last updated