Skip to content

Commit

Permalink
eclipse-ee4j#3753: need to bind ConstraintValidatorFactory
Browse files Browse the repository at this point in the history
Signed-off-by: pappy <pappy.stanescu@gmail.com>
  • Loading branch information
pa314159 committed Oct 4, 2019
1 parent 04aed84 commit 56b79f1
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -34,6 +34,7 @@
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.validation.Configuration;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.TraversableResolver;
import javax.validation.Validation;
import javax.validation.ValidationException;
Expand Down Expand Up @@ -73,6 +74,8 @@ protected void configure() {

bindFactory(ConfiguredValidatorProvider.class, Singleton.class).to(ConfiguredValidator.class);

bind(InjectingConstraintValidatorFactory.class).to(ConstraintValidatorFactory.class).in(Singleton.class);

// Custom Exception Mapper and Writer - registering in binder to make possible for users register their own providers.
bind(ValidationExceptionMapper.class).to(ExceptionMapper.class).in(Singleton.class);
bind(ValidationErrorMessageBodyWriter.class).to(MessageBodyWriter.class).in(Singleton.class);
Expand Down Expand Up @@ -257,7 +260,7 @@ private ValidatorContext getDefaultValidatorContext(final ValidateOnExecutionHan
final ValidatorContext context = factory.usingContext();

// Default Configuration.
context.constraintValidatorFactory(resourceContext.getResource(InjectingConstraintValidatorFactory.class));
context.constraintValidatorFactory(resourceContext.getResource(ConstraintValidatorFactory.class));

// Traversable Resolver.
context.traversableResolver(getTraversableResolver(factory.getTraversableResolver(), handler));
Expand Down

0 comments on commit 56b79f1

Please sign in to comment.