How can I access the pre-built constraint validations in Grails?
Lets say, for example, I want to use the range
validator on a Map
Object
Map<String, Double> myData
static constraints = {
myData validator: { val, obj, errors ->
//Iterate through all Double values and validate using `range` constraint
}
}
It doesn't seem to make sense to have to write my own range
validation method since Grails already has one built-in, somewhere. How can I access it?
Just to clarify, range
constraint is just an example. Just looking for how to access any of those pre-builts in general.
Update:
To clarify with a simpler example. I know how to use the constraints in the standard way. I am trying to use the constraint validations programmatically which I cannot find documentation for.
def myMethod() {
int myInt = 5;
//HOW DO I CALL RANGE (OR ANY) OF THE PRE-BUILT VALIDATION METHODS
if(RANGE(myInt, 0..5)) {
//DO SOMETHING
}
}
Like i said, I don't want to reinvent the wheel if it's already there. The API that the validation constraints use must be somewhere, how can I manually call those API's?