Created
October 25, 2012 16:11
-
-
Save sednem/3953728 to your computer and use it in GitHub Desktop.
Implementa a validação do annotation ISBN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.ufpe.nti.entity.beanValidation; | |
import javax.validation.ConstraintValidator; | |
import javax.validation.ConstraintValidatorContext; | |
public class ValidaISBN implements ConstraintValidator<ISBN, String>{ | |
public void initialize(ISBN constraintAnnotation) { | |
} | |
public boolean isValid(String object, ConstraintValidatorContext constraintContext) { | |
if (object == null){ | |
return false; | |
} | |
//Verifica se o ISBN possui 13 dígitos numéricos | |
if(object.length() == 13){ | |
return true; | |
}else{ | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment