Search code examples
validationgrailsinternationalizationbigdecimalgrails-domain-class

How does Grails handles between constraints and messages.properites


In my grails 2.3.11 project, I want to show Please enter a positive numeric value for salaryon my screen if the negative value is inputted. But it displayed Property [salary] with value [-9] is less than minimum value [0]

Constraints in my domain class

BigDecimal salary
static constraints = {
    salary nullable: false, min:0 as BigDecimal, scale: 2
}

Messages.properties

default.invalid.min.message=Property [{0}] with value [{2}] is less than minimum value [{3}]

employee.salary.invalid.min.message=Please enter a positive value for salary

I think the second line in the messages.properties is wrong, help me please!


Solution

  • To override the message, you would need

    employee.salary.min.notmet=Please enter a positive value for salary