Model validation: CodeValue
CodeValue
s define the set of allowed Strings
for a specific field in the model. For example in Inventory
, the field String formTypeCode
uses codes defined where CodeValue.groupName == "GERMPLASM_FORM"
.
Can we introduce a validator that will check that the provided String
value for Inventory#formTypeCode
is one of the defined CodeValue#value
in the specified group?
@Entity
class Inventory {
// ...
@Basic
@Column(name = "form_type_code", nullable = false, length = 20)
@CodeValue("GERMPLASM_FORM") // New validator
private String formTypeCode;