org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator Java Examples
The following examples show how to use
org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageCatalogV4BaseTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Before public void setUp() throws NoSuchFieldException, IllegalAccessException { Configuration<?> cfg = Validation.byDefaultProvider().configure(); cfg.messageInterpolator(new ParameterMessageInterpolator()); validator = cfg.buildValidatorFactory().getValidator(); for (Entry<String, Object> entry : Map.of("HTTP_CONTENT_SIZE_VALIDATOR", httpContentSizeValidator, "HTTP_HELPER", httpHelper).entrySet()) { Field field = ReflectionUtils.findField(ImageCatalogValidator.class, entry.getKey()); field.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); field.set(null, entry.getValue()); } when(httpContentSizeValidator.isValid(anyString(), any(ConstraintValidatorContext.class))).thenReturn(true); when(statusType.getFamily()).thenReturn(Family.SUCCESSFUL); }
Example #2
Source File: ValidationModule.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Provides @Singleton ValidatorFactory validatorFactory(ConstraintValidatorFactory constraintValidatorFactory) { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(HibernateValidator.class.getClassLoader()); ValidatorFactory factory = Validation.byDefaultProvider().configure() .constraintValidatorFactory(constraintValidatorFactory) .parameterNameProvider(new AopAwareParanamerParameterNameProvider()) .traversableResolver(new AlwaysTraversableResolver()) .messageInterpolator(new ParameterMessageInterpolator()) .buildValidatorFactory(); // FIXME: Install custom MessageInterpolator that can properly find/merge ValidationMessages.properties for bundles // exercise interpolator to preload elements (avoids issues later when TCCL might be different) factory.getValidator().validate(new Object() { // minimal token message @NotNull(message = "{org.sonatype.nexus.validation.constraint.notnull}") String empty; }); return factory; } finally { Thread.currentThread().setContextClassLoader(tccl); } }
Example #3
Source File: ParameterMessageInterpolaterIntegrationTest.java From tutorials with MIT License | 5 votes |
@BeforeClass public static void beforeClass() { ValidatorFactory validatorFactory = Validation.byDefaultProvider() .configure() .messageInterpolator(new ParameterMessageInterpolator()) .buildValidatorFactory(); validator = validatorFactory.getValidator(); }
Example #4
Source File: LearningSpringBootApplication.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 4 votes |
@Bean ParameterMessageInterpolator parameterMessageInterpolator() { return new ParameterMessageInterpolator(); }
Example #5
Source File: ParameterValidator.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
private AbstractMessageInterpolator messageInterpolator() { if (useResourceBundleMessageInterpolator()) { return new ResourceBundleMessageInterpolator(); } return new ParameterMessageInterpolator(); }
Example #6
Source File: ParameterValidatorFilter.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
private AbstractMessageInterpolator messageInterpolator() { if (useResourceBundleMessageInterpolator()) { return new ResourceBundleMessageInterpolator(); } return new ParameterMessageInterpolator(); }
Example #7
Source File: StackV4RequestCompatibilityTest.java From cloudbreak with Apache License 2.0 | 4 votes |
@Before public void setUp() { Configuration<?> cfg = Validation.byDefaultProvider().configure(); cfg.messageInterpolator(new ParameterMessageInterpolator()); validator = cfg.buildValidatorFactory().getValidator(); }