use of org.summerb.validation.ValidationContext in project summerb by skarpushin.
the class UsersServiceFacadeImpl method validateRegistration.
protected void validateRegistration(Registration registration) throws FieldValidationException {
ValidationContext ctx = new ValidationContext();
validateDisplayName(registration.getDisplayName(), ctx);
validatePassword(registration.getPassword(), ctx);
ctx.validateEmailFormat(registration.getEmail(), User.FN_EMAIL);
ctx.throwIfHasErrors();
}
use of org.summerb.validation.ValidationContext in project summerb by skarpushin.
the class UsersServiceFacadeImpl method validatePasswordReset.
protected void validatePasswordReset(PasswordReset resetPasswordRequest) throws FieldValidationException {
ValidationContext ctx = new ValidationContext();
validatePassword(resetPasswordRequest.getPassword(), ctx);
if (!resetPasswordRequest.getPassword().equals(resetPasswordRequest.getNewPasswordAgain())) {
ctx.add(new PasswordsDontMatchValidationError());
}
ctx.throwIfHasErrors();
}
use of org.summerb.validation.ValidationContext in project summerb by skarpushin.
the class UsersServiceFacadeImpl method validateUserIsEligableForPasswordReset.
protected void validateUserIsEligableForPasswordReset(String email) throws FieldValidationException {
ValidationContext ctx = new ValidationContext();
if (!ctx.validateEmailFormat(email, User.FN_EMAIL)) {
throw new FieldValidationException(ctx.getErrors());
}
// now see if this user exists
UserStatus userStatus = getUserStatusByEmail(email);
if (userStatus == UserStatus.NotExists || userStatus == UserStatus.Provisioned) {
throw new FieldValidationException(new RegistrationRequiredValidationError());
}
// Sanity check
if (userStatus != UserStatus.NormalUser && userStatus != UserStatus.AwaitingActivation) {
throw new RuntimeException("Password Reset scenario is not supported for user whose status is: " + userStatus);
}
}
use of org.summerb.validation.ValidationContext in project summerb by skarpushin.
the class EasyCrudValidationStrategyAbstract method validateForCreate.
@Override
public void validateForCreate(TDto dto) throws FieldValidationException {
ValidationContext ctx = new ValidationContext();
doValidateForCreate(dto, ctx);
if (ctx.getHasErrors()) {
throw new FieldValidationException(ctx.getErrors());
}
}
use of org.summerb.validation.ValidationContext in project summerb by skarpushin.
the class EasyCrudValidationStrategyAbstract method validateForUpdate.
@Override
public void validateForUpdate(TDto existingVersion, TDto newVersion) throws FieldValidationException {
ValidationContext ctx = new ValidationContext();
doValidateForUpdate(existingVersion, newVersion, ctx);
if (ctx.getHasErrors()) {
throw new FieldValidationException(ctx.getErrors());
}
}
Aggregations