Let's saying I have the following command:
@Validateable
class MyCommand {
String cancel_url
String redirect_url
String success_url
static constraints = {
cancel_url nullable: false, validator: { url, obj ->
//some specific validation
//some common url validation
}
redirect_url nullable: false, validator: { url, obj ->
//some specific validation
//some common url validation
}
success_url nullable: false, validator: { url, obj ->
//some specific validation
//some common url validation
}
}
}
Let's say I have some common validation I want to perform on any URL field (for instance, checking that the domain is allowed). What's the syntax to break this common validation code into a separate function instead of putting the same block in each validation closure?