| Total Complexity | 5 |
| Total Lines | 16 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | package com.osomapps.pt.tokenemail; |
||
| 7 | @Component |
||
| 8 | public class NameValidator implements Validator { |
||
| 9 | @Override |
||
| 10 | public boolean supports(final Class<?> aClass) { |
||
| 11 | return String.class.equals(aClass); |
||
| 12 | } |
||
| 13 | |||
| 14 | @Override |
||
| 15 | public void validate(final Object obj, final Errors errors) { |
||
| 16 | final String name = (String) obj; |
||
| 17 | if (name == null || name.trim().isEmpty()) { |
||
| 18 | errors.reject("name", "Invalid empty name"); |
||
| 19 | return; |
||
| 20 | } |
||
| 21 | if (name.trim().length() < 2) { |
||
| 22 | errors.reject("name", "Name should be at least 2 characters"); |
||
| 23 | } |
||
| 26 |