@FunctionalInterface public interface ProfileValidator
private static ProfileValidator checkDuplicateInDatabaseValidator() {
return (profile, profileIdentifier) -> {
GenericRejectionCause rejection = null;
boolean exist = ... exists in database?;
if (exist) {
rejection = GenericRejectionCause.rejectDuplicatedInDatabase(profileIdentifier);
}
return (rejection == null) ? Optional.empty() : Optional.of(rejection);
};
}
The call the method like this to validate the profile p:
GenericRejectionCause rejection = checkDuplicateInDatabaseValidator().validate(p, p.getName());
Check if rejection is present then do the resolution| Modifier and Type | Interface and Description |
|---|---|
static class |
ProfileValidator.RejectionCause
Rejection Cause
|
| Modifier and Type | Method and Description |
|---|---|
Optional<ProfileValidator.RejectionCause> |
validate(ProfileModel profile)
Validate a profile object
|
Optional<ProfileValidator.RejectionCause> validate(ProfileModel profile)
profile - to validateCopyright © 2020 Vitam. All rights reserved.