Results 1 to 3 of 3

Thread: Validation and comparing two fields - via annotaion?

  1. #1
    Join Date
    Feb 2009
    Posts
    7

    Question Validation and comparing two fields - via annotaion?

    I have an object that represents the form and having applied validation to the fields by means of annotations. I have two questions in this regards:
    - how to ensure value of a field matches that of another field, for example when ensuring the confirmation password matches the first
    - how to only apply the validation on a field based on the state of another field or session value.

    While I could do all of this within the controller or using a traditional validator, I want to see if it is possible via annotations.

  2. #2

    Default

    You need to write a class level validator. Check out the Hibernate site on this subject, Hibernate validation. I have used this approach before. With the approach, your code looks tidy, but you need to write some extra code you may not understand it later. It is easier to use the straight forward Spring validation code structure instead.
    [URL="http://vicina.info"] 新闻,社区新闻,分类广告

  3. #3

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •