use of org.summerb.approaches.validation.ValidationContext in project summerb by skarpushin.
the class StringTemplateValidationUtilsTest method testValidateStringTemplate_blackbox_expectOkForConstant.
@Test
public void testValidateStringTemplate_blackbox_expectOkForConstant() throws Exception {
StringTemplateCompiler stringTemplateCompiler = new StringTemplateCompilerlImpl();
String stringTemplate = "Constant text";
ValidationContext ctx = new ValidationContext();
String fieldToken = "fieldToken";
StringTemplateValidationUtils.validateStringTemplate(stringTemplateCompiler, stringTemplate, ctx, fieldToken);
assertEquals(false, ctx.getHasErrors());
}
use of org.summerb.approaches.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());
}
}
use of org.summerb.approaches.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.approaches.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.approaches.validation.ValidationContext in project summerb by skarpushin.
the class StringTemplateValidationUtilsTest method testValidateStringTemplate_blackbox_expectOkForValidExpression.
@Test
public void testValidateStringTemplate_blackbox_expectOkForValidExpression() throws Exception {
StringTemplateCompiler stringTemplateCompiler = new StringTemplateCompilerlImpl();
String stringTemplate = "Constant text plus ${vars['4444']}";
ValidationContext ctx = new ValidationContext();
String fieldToken = "fieldToken";
StringTemplateValidationUtils.validateStringTemplate(stringTemplateCompiler, stringTemplate, ctx, fieldToken);
assertEquals(false, ctx.getHasErrors());
}
Aggregations