@@ -0,0 +1,1624 @@
+package stopheracleum.validator;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.stereotype.Component;%0Aimport org.springframework.validation.Errors;%0Aimport org.springframework.validation.ValidationUtils;%0Aimport org.springframework.validation.Validator;%0Aimport stopheracleum.model.User;%0Aimport stopheracleum.service.UserService;%0A%0A/**%0A * Validator for %7B@link stopheracleum.model.User%7D class,%0A * implements %7B@link Validator%7D interface.%0A */%0A%0A@Component%0Apublic class UserValidator implements Validator %7B%0A%0A    @Autowired%0A    private UserService userService;%0A%0A    @Override%0A    public boolean supports(Class%3C?%3E aClass) %7B%0A        return User.class.equals(aClass);%0A    %7D%0A%0A    @Override%0A    public void validate(Object o, Errors errors) %7B%0A        User user = (User) o;%0A%0A        ValidationUtils.rejectIfEmptyOrWhitespace(errors, %22username%22, %22Required%22);%0A        if (user.getUsername().length() %3C 8 %7C%7C user.getUsername().length() %3E 32) %7B%0A            errors.rejectValue(%22username%22, %22Size.userForm.username%22);%0A        %7D%0A%0A        if (userService.findByUsername(user.getUsername()) != null) %7B%0A            errors.rejectValue(%22username%22, %22Duplicate.userForm.username%22);%0A        %7D%0A%0A        ValidationUtils.rejectIfEmptyOrWhitespace(errors, %22password%22, %22Required%22);%0A        if (user.getPassword().length() %3C 8 %7C%7C user.getPassword().length() %3E 32) %7B%0A            errors.rejectValue(%22password%22, %22Size.userForm.password%22);%0A        %7D%0A%0A        if (!user.getConfirmPassword().equals(user.getPassword())) %7B%0A            errors.rejectValue(%22confirmPassword%22, %22Different.userForm.password%22);%0A        %7D%0A    %7D%0A%7D%0A%0A%0A

Add data validator for user class