Reputation: 1560
My Entity Class property portion is given below:
@Entity
@Table(name="rules")
public class Rule {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long id;
@NotEmpty
@Size(min=4, max=128)
@Column(length = 128, nullable = false)
private String name;
@Column
private String assetType;
@Min(value=1, message="Minimum value should be 1")
@Column(name = "min_quantity")
private int min_quantity;
@Min(value=1L, message="Minimum value should be 1")
@Column
private int warningAt;
@Column
private boolean status;
In html form:
<div class="has-error">
<form:errors path="min_quantity" />
</div>
I am getting below error during form validator:
"Failed to convert property value of type java.lang.String to required type int for property min_quantity; nested exception is java.lang.NumberFormatException: For input string: """
In my form its not showing my custom message.
Upvotes: 0
Views: 2955
Reputation: 57421
@Min is applied to numbers not strings
Use
@Length(min = 1, message = "Minimum value should be 1")
Upvotes: 1