0
votes

I'm using Hibernate Validator and added some custom validation annotations, resource bundle location and a custom message interpolator. This is all done by customizing the Validator at bootstrapping time.

Now I'm trying to validate methods, but of course I don't get my nicely configured Validator, since the standard Validator is injected for @AutoValidating.

How can I customize the Validator within Seam Validation?


Here's how I create the Validator:

public static javax.validation.Validator getBeanValidator(final Locale locale,
    final ResourceBundle... resourceBundles) {
  HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class).configure();
  FallbackResourceBundleLocator resourceBundleLocator = new FallbackResourceBundleLocator(
      configuration.getDefaultResourceBundleLocator(), resourceBundles);
  configuration.messageInterpolator(new FieldMessageInterpolator(locale, resourceBundleLocator));
  javax.validation.ValidatorFactory validatorFactory = configuration.buildValidatorFactory();
  return validatorFactory.getValidator();
}
1

1 Answers

0
votes

You could try to configure the default validator using META-INF/validation.xml, which is the validator used by Seam Validation.

Alternatively you could create your own interceptor based on the one from Seam Validation, and use your custom configured Validator there.