0
votes

Now, I am developing a web application with Spring MVC.

And in my project, I try to use HIBERNATE VALIDATOR for form validation.

In a table of database for my project, the following field is included.

[rate] numeric(5,2)

So, I want to add a validation for that field, and I declare field in my bean as follow:

private double rate;

But, I don't know how to validate the value of the field using hibernate validator.

So, I try to get help from GOOGLE, but I don't get a good solution for my problem.

The sample values can be "0.05", "1.00", "12.55", etc.

Therefore, if any way to solve this problem, please light-up me. Thanks.

1

1 Answers

0
votes

You can use @Digits annotation as follow:

@Digits(integer=5, fraction=2)
@Column(name = "rate")
private BigDecimal rate;

Good Luck!!!