I'm using grails JQuery Validation UI Plugin for grails 2.1.0.
I nearly have my form valadting client side based on my command object constraints. There is one problem, I have a custom constraint in my command object:
startTime(nullable: false, validator: {startTime, deal ->
if ((!DateUtils.isSameDay(startTime, new Date()) && startTime.before(new Date()))) //Start date is today or future but not before end date
{
return "pastDate"
}
if (deal.endTime && startTime.after(deal.endTime)) {
return "before.endTime"
}
})
This results in the following rendered jQuery validation code generated with page markup:
startTime: {
date: true,
required: true,
validator: {
url: '/appContextRoot/JQueryRemoteValidator/validate',
type: 'post',
data: {
validatableClass: 'myapp.command.tester.testerDealCommand',
property: 'startTime'
}
}
}
The custum constrains logic withing "validator:" does nothing currently.
What is the best approach to get this custom validator working?
1: Some form of Ajax call?
2: Use Custom Constraits plugin and add js code to grails-validation-methods.js?
3: Some other way?
I'm unsure of using option 2....is there some way to extend the plugin?
I do not want to have to commit and maintain a seperate version of the plugin in our source code repository.