Reputation: 2359
In Grails domain class i have Field
BigDecimal grossWeight
and constraint for it
static constraints = {
grossWeight(nullable: true, min: BigDecimal.ZERO, scale: 3)
}
I like to have test for scale constraint but don't know how to implement it
Following not works
formxItem = new FormXItem(grossWeight: new BigDecimal("0.1234"))
assert !formxItem.validate()
assertNotNull formxItem.errors['grossWeight']
Upvotes: 3
Views: 476
Reputation: 3881
According to the documentation for scale, the constraint does not register any validation errors, so it will not fail validation. Instead it sets the column's precision in the database and automatically scales down the precision of the number, if necessary.
Upvotes: 2