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:
box install cbvalidationDefining 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.
<cfscript>
constraints = {
"task": { required: true }
};
// Data Properties
data = {
"task": ""
};
</cfscript>
<cfoutput>
<div>
<!-- HTML goes here -->
</div>
</cfoutput>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.
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