You can build also your own validators by implementing our interface cbvalidaton.models.validators.IValidator
:
The arguments received are:
validationResults
: The validation result object
field
: The field or property in the object that is in validation
targetValue
: The value to test
Here is a sample validator:
WARNING: You can't do a normal wirebox mapping for YourOwnValidator
in your main application. A validator needs an IValidator
interface from the cbvalidation
module. When wirebox inspects the binder, the cbvalidation
module is not loaded yet, so it will error. This can be solved by defining your custom validators in an own module (depending on cbvalidation
) or by mapping your validator in the afterConfigurationLoad()
method of your binder, e.g in config/wirebox.cfc