File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Problem in ValidationUtils Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Problem in ValidationUtils" Watch "Problem in ValidationUtils" New topic

Problem in ValidationUtils

Anupam Dee
Ranch Hand

Joined: Oct 18, 2010
Posts: 42

I have two fields in Person Class

I want to validate that both the names should be given by the user at the same time

ValidationUtils only gives the method to check on a particular field, how can I validate this?
Bill Gorder

Joined: Mar 07, 2010
Posts: 1682

You can do client side validation using javascript.

Put hibernate validator on your class path.

In your spring controller you can add @Valid to the model object you wish to validate. Then just use the JSR-303 annotations on your fields. Like @NotBlank or @NotNull.

Here is an example.

[How To Ask Questions][Read before you PM me]
It is sorta covered in the JavaRanch Style Guide.
subject: Problem in ValidationUtils
It's not a secret anymore!