Projekt

Obecné

Profil

Stáhnout (976 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1
package cz.zcu.kiv.backendapi.validation;
2

    
3
import cz.zcu.kiv.backendapi.user.password.PasswordDto;
4

    
5
import javax.validation.ConstraintValidator;
6
import javax.validation.ConstraintValidatorContext;
7

    
8
/**
9
 * Validator for password and confirmation password
10
 */
11
public class PasswordMatchesValidator implements ConstraintValidator<PasswordMatches, PasswordDto> {
12

    
13
    /**
14
     * Checks if password and confirmation password match
15
     *
16
     * @param passwordDto                password DTO
17
     * @param constraintValidatorContext constraint validator context
18
     * @return true if passwords matches, false otherwise
19
     */
20
    @Override
21
    public boolean isValid(PasswordDto passwordDto, ConstraintValidatorContext constraintValidatorContext) {
22
        if (passwordDto.getPassword() == null || passwordDto.getConfirmationPassword() == null) {
23
            return false;
24
        }
25
        return passwordDto.getPassword().equals(passwordDto.getConfirmationPassword());
26
    }
27
}
(3-3/4)