You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use this skill when validating user input in ColdBox/BoxLang using cbvalidation. Covers constraint definitions, validate()/validateOrFail() calls, built-in validators, custom validators, shared constraint files, error handling in handlers, and integrating validation results with views and REST APIs.
applyTo
**/*.{bx,cfc,cfm,bxm}
CBValidation Skill
When to Use This Skill
Load this skill when:
Validating form input or API payloads in handlers
Defining reusable constraint sets or per-field rules
Catching ValidationException and returning structured error responses
Adding custom validators for domain-specific rules
Integrating validation errors with views or JSON API responses
// models/validators/StrongPasswordValidator.bxclassimplements="cbvalidation.models.validators.IValidator"{stringthis.name="StrongPassword"booleanfunctionisValid(value,validationData,targetValue,target){if(!len(value))returntrue// delegate to 'required'return(reFind("[A-Z]",value)&&// uppercasereFind("[0-9]",value)&&// digitreFind("[!@#$%]",value)&&// special charlen(value)>=8)}stringfunctiongetDefaultMessage(validationData){return"Password must be at least 8 characters with an uppercase letter, number, and special character."}}
// Register in config/WireBox.cfcbinder.map("StrongPasswordValidator@cbvalidation").to("models.validators.StrongPasswordValidator")
// Use in constraint
password : {required : true,validator : "StrongPassword"}