3

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']
Aram Arabyan
  • 2,339
  • 1
  • 17
  • 30

1 Answers1

2

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.

schmolly159
  • 3,881
  • 17
  • 26