[abportal] Annotation of /src/main/java/eu/smartlm/abs/portal/security/login/admin/MyValidator.java
Annotation of /src/main/java/eu/smartlm/abs/portal/security/login/admin/MyValidator.java
Parent Directory
| Revision Log
Revision 1 -
(view)
(download)
1 : |
dgarcia |
1 |
package eu.smartlm.abs.portal.security.login.admin;
|
2 : |
|
|
|
3 : |
|
|
import org.springframework.validation.Errors;
|
4 : |
|
|
import org.springframework.validation.ValidationUtils;
|
5 : |
|
|
import org.springframework.validation.Validator;
|
6 : |
|
|
|
7 : |
|
|
import eu.smartlm.abs.portal.security.login.model.User;
|
8 : |
|
|
|
9 : |
|
|
/**
|
10 : |
|
|
* Validates that user is ok when the data is introduced in the form
|
11 : |
|
|
* @author David García Pérez - CESGA
|
12 : |
|
|
*/
|
13 : |
|
|
public class MyValidator implements Validator {
|
14 : |
|
|
|
15 : |
|
|
public boolean supports(Class<?> klass) {
|
16 : |
|
|
return User.class.isAssignableFrom(klass);
|
17 : |
|
|
}
|
18 : |
|
|
|
19 : |
|
|
public void validate(Object target, Errors errors) {
|
20 : |
|
|
//User user = (User) target;
|
21 : |
|
|
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "NotEmpty.user.username");
|
22 : |
|
|
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "NotEmpty.user.password");
|
23 : |
|
|
}
|
24 : |
|
|
}
|
|