1

I currently galley with data validation via Hibernate. Especially with the @Pattern annotation

Wholesale verification is always false, no matter what I do, so I can not save the object.

I try this, among other things:

@NotNull
@Size(max=30)
@SafeHtml
@Pattern(regexp="[a-zA-Z]", messsage="the name can only contain letters")
private String name;

et ceci :

@NotNull
@Size(max=30)
@SafeHtml
@Pattern(regexp="\\D", messsage="the name can only contain letters")
private String name;

In both case, if i write "toto," I have the error message that appears.

Someone an idea?

1 Answer 1

2

Have you tried [a-zA-Z]*

The patterns you have look like they only capture one letter. You need a * or a + to suggest multiple letters.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.