Can anyone show me how to declare an inList
constraint within a Grails controller?
Let’s say I have this class:
class A {
List hello
}
How can I add the inList
constraint for the hello
List
from within the controller?
Can anyone show me how to declare an inList
constraint within a Grails controller?
Let’s say I have this class:
class A {
List hello
}
How can I add the inList
constraint for the hello
List
from within the controller?
Define a constraint in which a
List
property has values validated against a list of lists? Sounds weird. But you can do it. With this class:you can do this in your controller:
If
A
is a domain class whose instances are persisted in a traditional database, however, thehello
property would be dropped, so you’d need to define it usinginstead.
You can write a custom validator to your fields that check if data are in List. You will have to implement the in list checking manually. You can find here the official documentation. There are some stackoverflow entries that can help you like
Grails: Custom validator based on a previous value of the field