I have an issue where my domain class has two potential mutually exclusive external keys, either a serial number or a legacy lookup value.
Since I'm not sure which one I'll have for any given entry, I've made them both nullable and added custom validation to try to ensure I have one and only one value.
package myproject
class Sample {
String information
String legacyLookup
String serialNumber
static constraints = {
information(nullable: true)
legacyLookup(nullable: true)
serialNumber(nullable: true)
legacyLookup validator: {
return ((serialNumber != null && legacyLookup == null) || (serialNumber == null && legacyLookup != null))
}
serialNumber validator: {
return ((serialNumber != null && legacyLookup == null) || (serialNumber == null && legacyLookup != null))
}
}
}
I created the default CRUD screens and tried to create an entry for this domain class
information: Blah Blah
serialNumber:
legacyLookup: BLAHINDEX123
This dies in the validator with the following message:
No such property: serialNumber for class: myproject.Sample
What am I missing?