I’m having some trouble using a specific feature of the validation that is in CB 3.5.
Here are my constraints:
this.constraints = {
‘label’ = {
required = true,
size=‘2…100’,
requiredMessage = ‘A Product Name is required.’,
sizeMessage = ‘It must be between 2 and 100 characters.’
},
‘price’ = {
required = true,
type = ‘numeric’,
requiredMessage = ‘A Product Price is required.’,
typeMessage = ‘It must be numeric.’
},
‘producttype’ = {
method = ‘ProductTypeConstraint’,
methodMessage = ‘A Product must have a product type.’
},
‘currencycode’ = {
method = ‘CurrencyCodeConstraint’,
methodMessage = ‘A Product must have a currency code.’
}
};
First two are straight forward. Second 2 are orm relationship properties, and what they do is very simple:
public boolean function ProductTypeConstraint(Any Value, Any Target) {
return ( arguments.Target.hasProductType() ? true : false );
}
public boolean function CurrencyCodeConstraint(Any Value, Any Target) {
return ( arguments.Target.hasCurrencyCode() ? true : false );
}
The problem is, CB will error with