I am using bean validation with annotations in my JSF project. I was wondering, how to create annotations for password confirmation and how to validate that an email doesn’t exist in database?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This kind of validation is not really applicable on entities.
Userentities do not hold double password fields, instead they hold just a single password field. Also entities do not necessarily hold an email field with a value which do not exist in the DB. You would end up with false errors whenever you want to edit an existing entity.I suggest you to do this validation in the view side, right before the entity is to be persisted in the DB. In JSF you can use
Validatorfor this. You can find examples of a password confirmation validator in the answers on this question: How validate two password fields by ajax?