org.hibernate.validator.spi.resourceloading.ResourceBundleLocator Java Examples

The following examples show how to use org.hibernate.validator.spi.resourceloading.ResourceBundleLocator. 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: ValidatorContextResolver.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
public GeneralValidator getContext(final Class<?> type) {
    final ResourceBundleLocator resourceBundleLocator = new PlatformResourceBundleLocator("messages");
    final MessageInterpolator messageInterpolator = new ResourceBundleMessageInterpolator(resourceBundleLocator);
    final Configuration<?> config = Validation.byDefaultProvider().configure()
        .messageInterpolator(messageInterpolator);
    final BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    final boolean isExecutableValidationEnabled = bootstrapConfiguration.isExecutableValidationEnabled();
    final Set<ExecutableType> defaultValidatedExecutableTypes = bootstrapConfiguration
        .getDefaultValidatedExecutableTypes();

    return new GeneralValidatorImpl(validatorFactory, isExecutableValidationEnabled,
        defaultValidatedExecutableTypes);
}
 
Example #2
Source File: ActionValidator.java    From lastaflute with Apache License 2.0 5 votes vote down vote up
protected ResourceBundleLocator newResourceBundleLocator() {
    return ignoredLocale -> {
        // not used default locacle managed in Hibernate validator,
        // all messages use provided locale (e.g. request locale)
        // to match with other message's locale
        final Locale provided = messageLocaleProvider.provide();
        return newHookedResourceBundle(provided);
    };
}
 
Example #3
Source File: ValidationFeature.java    From ameba with MIT License 4 votes vote down vote up
private ResourceBundleLocator buildBundleLocator(final String name) {
    return locale -> Messages.getResourceBundle(name, locale);
}