本文整理汇总了Java中org.hibernate.validator.HibernateValidatorConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java HibernateValidatorConfiguration类的具体用法?Java HibernateValidatorConfiguration怎么用?Java HibernateValidatorConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HibernateValidatorConfiguration类属于org.hibernate.validator包,在下文中一共展示了HibernateValidatorConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class)
.configure();
configuration.parameterNameProvider(new ReflectionParameterNameProvider());
configuration.messageInterpolator(new LocaleSpecificMessageInterpolator(configuration
.getDefaultMessageInterpolator()));
validatorFactory = configuration.buildValidatorFactory();
Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_VENDOR, "AdeptJ");
props.put(Constants.SERVICE_DESCRIPTION, "AdeptJ ValidatorService");
servRegValidatorService = context.registerService(ValidatorService.class,
new OSGiBeanValidatorService(this.validatorFactory.getValidator(),
configuration.getBootstrapConfiguration()),
props);
}
示例2: getPropertyConfiguredValidatedValueHandlers
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
/**
* Returns a list with {@link ValidatedValueUnwrapper}s configured via the
* {@link HibernateValidatorConfiguration#VALIDATED_VALUE_HANDLERS}
* property.
*
* @param properties
* the properties used to bootstrap the factory
*
* @return a list with property-configured {@link ValidatedValueUnwrapper}s;
* May be empty but never {@code null}
*/
private List<ValidatedValueUnwrapper<?>> getPropertyConfiguredValidatedValueHandlers(Map<String, String> properties) {
String propertyValue = properties.get(HibernateValidatorConfiguration.VALIDATED_VALUE_HANDLERS);
if (propertyValue == null || propertyValue.isEmpty()) {
return Collections.emptyList();
}
String[] handlerNames = propertyValue.split(",");
List<ValidatedValueUnwrapper<?>> handlers = newArrayList(handlerNames.length);
for (String handlerName : handlerNames) {
@SuppressWarnings("unchecked")
Class<? extends ValidatedValueUnwrapper<?>> handlerType = (Class<? extends ValidatedValueUnwrapper<?>>) run(LoadClass
.action(handlerName, ValidatorFactoryImpl513.class));
handlers.add(run(NewInstance.action(handlerType, "validated value handler class")));
}
return handlers;
}
示例3: createConfiguration
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
/**
* create hibernate validation configuration
*
* @return
*/
protected HibernateValidatorConfiguration createConfiguration() {
HibernateValidatorConfiguration configuration = null;
if (this.isIgnoreClassHierarchy()) {
ValidationProviderResolver resolver = new ValidationProviderResolver() {
/**
* (non-Javadoc)
*
* @see javax.validation.ValidationProviderResolver#getValidationProviders()
*/
@Override
public List<ValidationProvider<?>> getValidationProviders() {
List<ValidationProvider<?>> providers = new ArrayList<ValidationProvider<?>>(1);
providers.add(new HibernateValidator513());
return providers;
}
};
configuration = Validation.byProvider(HibernateValidator513.class).providerResolver(resolver).configure();
} else {
configuration = Validation.byProvider(HibernateValidator.class).configure();
}
configuration.messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator(
MESSAGES)));
return configuration;
}
示例4: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping
.type(SysRole.class)
.property("roleName", ElementType.FIELD)
.constraint(new SizeDef().max(32))
.constraint(new NotNullDef())
.constraint(new PatternDef().regexp("^(?!root$).+$").message(
"may not be root"))
.property("roleCode", ElementType.FIELD)
.constraint(new NotNullDef()).constraint(new SizeDef().max(32));
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例5: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping
.type(SysRoute.class)
.property("routeId", ElementType.FIELD)
.constraint(new NotNullDef())
.property("name", ElementType.FIELD)
.constraint(new SizeDef().max(32))
.property("url", ElementType.FIELD)
.constraint(new SizeDef().max(128))
.constraint(new PatternDef()
.regexp("(/:?[0-9a-zA-Z_]+)*")
.message("{msg.error.validation.routeUrl.pattern}"));
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例6: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping
.type(SysMenu.class)
.property("menuName", ElementType.FIELD)
.constraint(new SizeDef().max(32))
.constraint(new NotNullDef())
.property("menuPath", ElementType.FIELD)
.constraint(new SizeDef().max(128))
.constraint(new PatternDef()
.regexp("(/:?[0-9a-zA-Z_]+)*")
.message("{msg.error.validation.routeUrl.pattern}"))
.property("parentId", ElementType.FIELD)
.constraint(new NotNullDef())
.property("icon", ElementType.FIELD)
.constraint(new SizeDef().max(32));
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例7: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping
.type(SysUser.class)
.property("userId", ElementType.FIELD)
.constraint(new NotNullDef())
.property("username", ElementType.FIELD)
.constraint(new SizeDef().max(16).min(3))
.constraint(new PatternDef().regexp("[a-zA-Z][0-9a-zA-Z_]*")
.message("{msg.error.validation.username.pattern}"))
.property("password", ElementType.FIELD)
.constraint(new SizeDef().max(16).min(6))
.property("fullName", ElementType.FIELD)
.constraint(new SizeDef().max(32))
.property("email", ElementType.FIELD).constraint(new EmailDef())
.constraint(new SizeDef().max(64));
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例8: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping.type(SysRole.class).property("roleId", ElementType.FIELD)
.constraint(new NotNullDef())
.property("roleName", ElementType.FIELD)
.constraint(new SizeDef().max(32))
.constraint(new PatternDef().regexp("^(?!root$).+$").message("may not be root"))
.property("roleCode", ElementType.FIELD)
.constraint(new SizeDef().max(32));
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例9: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping
.type(SysUser.class)
.property("username", ElementType.FIELD)
.constraint(new NotNullDef())
.constraint(new SizeDef().max(16).min(3))
.constraint(new PatternDef().regexp("[a-zA-Z][0-9a-zA-Z_]*")
.message("{msg.error.validation.username.pattern}"))
.property("password", ElementType.FIELD)
.constraint(new SizeDef().max(16).min(6))
.constraint(new NotNullDef())
.property("fullName", ElementType.FIELD)
.constraint(new NotNullDef()).constraint(new SizeDef().max(32))
.property("email", ElementType.FIELD)
.constraint(new SizeDef().max(64)).constraint(new EmailDef());
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例10: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping.type(ChangePasswordVo.class)
.property("oldpassword", ElementType.FIELD)
.constraint(new SizeDef().max(16).min(6))
.constraint(new NotNullDef())
.property("newpassword", ElementType.FIELD)
.constraint(new SizeDef().max(16).min(6))
.constraint(new NotNullDef())
.property("retypepassword", ElementType.FIELD)
.constraint(new SizeDef().max(16).min(6))
.constraint(new NotNullDef());
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例11: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping
.type(SysMenu.class)
.property("menuId", ElementType.FIELD)
.constraint(new NotNullDef())
.property("menuName", ElementType.FIELD)
.constraint(new SizeDef().max(32))
.property("menuPath", ElementType.FIELD)
.constraint(new SizeDef().max(128))
.constraint(new PatternDef()
.regexp("(/:?[0-9a-zA-Z_]+)*")
.message("{msg.error.validation.routeUrl.pattern}"))
.property("icon", ElementType.FIELD)
.constraint(new SizeDef().max(32));
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例12: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping
.type(SysRoute.class)
.property("name", ElementType.FIELD)
.constraint(new SizeDef().max(32))
.constraint(new NotNullDef())
.property("url", ElementType.FIELD)
.constraint(new NotNullDef())
.constraint(new SizeDef().max(128))
.constraint(new PatternDef()
.regexp("(/:?[0-9a-zA-Z_]+)*")
.message("{msg.error.validation.routeUrl.pattern}"));
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例13: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping.type(SysJob.class).property("jobId", ElementType.FIELD)
.constraint(new NotNullDef())
.property("clazzName", ElementType.FIELD).constraint(new NullDef())
.property("jobName", ElementType.FIELD)
.constraint(new SizeDef().max(32))
.property("cron", ElementType.FIELD)
.constraint(new SizeDef().max(32));
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例14: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping
.type(SysJob.class)
.property("clazzName", ElementType.FIELD)
.constraint(new NotNullDef())
.constraint(new SizeDef().max(64))
.constraint(new PatternDef().regexp("[a-zA-Z.]+")
.message("{msg.error.validation.className.pattern}"))
.property("jobName", ElementType.FIELD)
.constraint(new SizeDef().max(32)).constraint(new NotNullDef())
.property("cron", ElementType.FIELD)
.constraint(new SizeDef().max(32)).constraint(new NotNullDef());
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}
示例15: createValidator
import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
HibernateValidatorConfiguration configuration = Validation.byProvider(
HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
constraintMapping
.type(SysDict.class)
.property("dictCode", ElementType.FIELD)
.constraint(new SizeDef().max(32))
.constraint(new NotNullDef())
.constraint(new PatternDef().regexp("[0-9a-zA-Z_]+").message(
"{msg.error.validation.dictCode.pattern}"))
.property("dictName", ElementType.FIELD)
.constraint(new SizeDef().max(32)).constraint(new NotNullDef());
return configuration.addMapping(constraintMapping).buildValidatorFactory()
.getValidator();
}