Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.0.1
-
Fix Version/s: 1.0.2
-
Component/s: Persistence
-
Labels:None
-
Environment:N/A
Description
Constraint logic is incorrect. All constraints should evaluate to true before writing object to database. This is especially problematic with nullable.
This constraint will evauate to true if the user leaves the field blank:
static constraints = {
field (validator: {return false}, nullable:true)
}
A real world example would look like this:
class Book {
Boolean published
String isbn
plus several more fields that become required if book is published
static constraints = {
isbn (validator: {val,obj -> if (obj.published && !val)) return false}, nullable:true)
}
}
Issue Links
| This issue is duplicated by: | ||||
| GRAILS-2656 | Add nullable/blank constraint vetoing capability to domain constraints |
|
|
|
I'm not sure what the issue is exactly, please elaborate on the what the problem is and attach an example app