Reputation: 179
Hi how do I set the command object constraint nullable, blank, and custom for these 2 list, event[] and qty[] from the below html?
<div class="row-1">
<select name="event[]" class="form-control ">
<option selected="">abc</option>
<option selected="">def</option>
</select>
<input name="qty[]" >
</div>
<div class="row-2">
<select name="event[]" class="form-control ">
<option selected="">ghi</option>
<option selected="">jkl</option>
</select>
<input name="qty[]" >
</div>
class someCommand implements Validateable {
List eventComponent
List qty
static constraints = {
}
}
Upvotes: -1
Views: 334
Reputation: 27220
Hi how do I set the command object constraint nullable, blank, and custom for these 2 list
You could do something like this:
class someCommand implements Validateable {
List eventComponent
List qty
static constraints = {
eventComponent nullable: false, validator: { theList ->
// return true if theList is valid
// return false or a message code if theList is invalid
}
qty nullable: false
}
}
You wouldn't use blank
for a List
. blank
is for validating String
properties. If you want to make sure the list has elements in it, you could use minSize: 1
.
I hope that helps.
Upvotes: 0