Last change
on this file since 1ad8e64 was 1ad8e64, checked in by Ema <ema_spirova@…>, 3 years ago |
spring security
|
-
Property mode
set to
100644
|
File size:
837 bytes
|
Rev | Line | |
---|
[1ad8e64] | 1 | package finki.diplomska.tripplanner.validator;
|
---|
| 2 |
|
---|
| 3 | import finki.diplomska.tripplanner.models.User;
|
---|
| 4 | import org.springframework.stereotype.Component;
|
---|
| 5 | import org.springframework.validation.Errors;
|
---|
| 6 | import org.springframework.validation.Validator;
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | @Component
|
---|
| 10 | public class UserValidator implements Validator {
|
---|
| 11 | @Override
|
---|
| 12 | public boolean supports(Class<?> aClass) {
|
---|
| 13 | return User.class.equals(aClass);
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | @Override
|
---|
| 17 | public void validate(Object object, Errors errors) {
|
---|
| 18 | User user = (User) object;
|
---|
| 19 | if(user.getPassword().length() < 6){
|
---|
| 20 | errors.rejectValue("password","Length", "Password must be at least 6 characters" );
|
---|
| 21 | }
|
---|
| 22 | if(!user.getPassword().equals(user.getConfirmPassword())){
|
---|
| 23 | errors.rejectValue("confirmPassword", "Match", "Password must match");
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.