Stephen Tun Aung
Stephen Tun Aung

Reputation: 992

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!

Upvotes: 0

Views: 60

Answers (1)

Frederic Henri
Frederic Henri

Reputation: 53713

To override the message, you would need

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

Upvotes: 1

Related Questions