I am trying to validate user input password against set of rules and here are those rules.
this is what i have done so far in my bean class
@NotNull(message = "{register.pwd.invalid}")
@Size(min = 6, max = 8, message = "{register.pwd.invalid}")
public String getPwd()
{
return pwd;
}
I believe for the rest part i have to use regExp but not sure what regular expression i need to have, this is what i came up
^.*(?=.{6,8})(?=.*\d)(?=.*[A-Z]).*$
i am not sure about the expression as i am not good in regExp,can any one help me to point in correcting the regExp
You are quite close
^(?=.*\d)(?=.*[A-Z]).{6,8}$
Don't use .*
at the start (it would sabotage the length check) and move the length check to the end.