Reputation: 3548
I have an Entity bean and one of its String-type properties has a @Size
annotation as follows:
@PSanityCheck
@Size(min = 8, max = 8, message = "validation.servicecode_length")
@NotEmptyData
@Column(name = "servicecode")
@Field
private String servicecode= "";
However, if I type a string containing a whitespace in the beginning, for example " 1234567" it will accept it as input made of 8 characters. How to make it trim off the whitespace? Is there an annotation for that? The UI is made with Vaadin-framework.
Upvotes: 0
Views: 2259
Reputation: 58
You can use the @Pattern annotation with a regular Expression for this
Upvotes: 2