Search in sources :

Example 11 with ValidationContext

use of org.summerb.approaches.validation.ValidationContext in project summerb by skarpushin.

the class UserServiceImpl method validateUser.

private void validateUser(User user) throws FieldValidationException {
    ValidationContext ctx = new ValidationContext();
    validateEmail(user.getEmail(), ctx);
    ctx.validateDataLengthLessOrEqual(user.getDisplayName(), User.FN_DISPLAY_NAME_SIZE, User.FN_DISPLAY_NAME);
    if (ctx.getHasErrors()) {
        throw new FieldValidationException(ctx.getErrors());
    }
}
Also used : FieldValidationException(org.summerb.approaches.validation.FieldValidationException) ValidationContext(org.summerb.approaches.validation.ValidationContext)

Example 12 with ValidationContext

use of org.summerb.approaches.validation.ValidationContext in project summerb by skarpushin.

the class UserServiceImpl method validateEmail.

private void validateEmail(String email) throws FieldValidationException {
    ValidationContext ctx = new ValidationContext();
    validateEmail(email, ctx);
    if (ctx.getHasErrors()) {
        throw new FieldValidationException(ctx.getErrors());
    }
}
Also used : FieldValidationException(org.summerb.approaches.validation.FieldValidationException) ValidationContext(org.summerb.approaches.validation.ValidationContext)

Aggregations

ValidationContext (org.summerb.approaches.validation.ValidationContext)12 FieldValidationException (org.summerb.approaches.validation.FieldValidationException)5 Test (org.junit.Test)3 StringTemplateCompiler (org.summerb.utils.stringtemplate.api.StringTemplateCompiler)3 StringTemplateCompilerlImpl (org.summerb.utils.stringtemplate.impl.StringTemplateCompilerlImpl)3 User (org.summerb.microservices.users.api.dto.User)2 UserStatus (org.summerb.approaches.springmvc.security.dto.UserStatus)1 PasswordsDontMatchValidationError (org.summerb.approaches.springmvc.security.ve.PasswordsDontMatchValidationError)1 RegistrationRequiredValidationError (org.summerb.approaches.springmvc.security.ve.RegistrationRequiredValidationError)1 UserNotFoundException (org.summerb.microservices.users.api.exceptions.UserNotFoundException)1