当前位置: 首页>>代码示例>>Java>>正文


Java HibernateValidatorConfiguration.createConstraintMapping方法代码示例

本文整理汇总了Java中org.hibernate.validator.HibernateValidatorConfiguration.createConstraintMapping方法的典型用法代码示例。如果您正苦于以下问题:Java HibernateValidatorConfiguration.createConstraintMapping方法的具体用法?Java HibernateValidatorConfiguration.createConstraintMapping怎么用?Java HibernateValidatorConfiguration.createConstraintMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.validator.HibernateValidatorConfiguration的用法示例。


在下文中一共展示了HibernateValidatorConfiguration.createConstraintMapping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:20,代码来源:SysRoleValidator.java

示例2: 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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:22,代码来源:SysRouteUpdateValidator.java

示例3: 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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:SysMenuValidator.java

示例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(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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:SysUserUpdateValidator.java

示例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(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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:19,代码来源:SysRoleUpdateValidator.java

示例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(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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:SysUserValidator.java

示例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(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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:21,代码来源:PasswordValidator.java

示例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(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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:24,代码来源:SysMenuUpdateValidator.java

示例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(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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:22,代码来源:SysRouteValidator.java

示例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(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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:18,代码来源:SysJobUpdateValidator.java

示例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(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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:22,代码来源:SysJobValidator.java

示例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(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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:20,代码来源:SysDictValidator.java

示例13: postProcessConfiguration

import org.hibernate.validator.HibernateValidatorConfiguration; //导入方法依赖的package包/类
@Override
protected void postProcessConfiguration(Configuration<?> configuration) {
    super.postProcessConfiguration(configuration);
    HibernateValidatorConfiguration hibernateConfiguration = (HibernateValidatorConfiguration) configuration;

    ConstraintMapping constraintMapping = hibernateConfiguration.createConstraintMapping();
    validators.forEach(validator -> addConstraint(constraintMapping, validator));
    hibernateConfiguration.addMapping(constraintMapping);

    hibernateValidatorConfigurationStrategy.accept(hibernateConfiguration);
}
 
开发者ID:infobip,项目名称:infobip-bean-validation,代码行数:12,代码来源:CustomLocalValidatorFactoryBean.java

示例14: getPolicyTriggerRange

import org.hibernate.validator.HibernateValidatorConfiguration; //导入方法依赖的package包/类
public static HibernateValidatorConfiguration getPolicyTriggerRange(HibernateValidatorConfiguration config) {

		 Map<String, Map<String, Map<String, Map<String, String>>>> mulit_range = Constants.getTriggerRangeByTriggerType();
		 logger.debug("mulit trigger range: " + mulit_range.toString());
		 for (String class_type : mulit_range.keySet()){
			 Map<String, Map<String, Map<String, String>>> range = mulit_range.get(class_type);
			 Class<?> class_obj=null;
			 if (class_type.equals("trigger_Memory")) //only one metricType supported now
				 class_obj = PolicyTrigger.class;
			 for (String key : range.keySet()) {
				 Map<String, Map<String, String>> value = range.get(key);
				 for(String value_key : value.keySet()){
					 Map<String, String> value_item = value.get(value_key);
					 ConstraintMapping mapping = config.createConstraintMapping();
					 if (value_key.endsWith("Min")){
						 mapping.type(class_obj).property(key, ElementType.FIELD).constraint( new MinDef().value(Integer.parseInt(value_item.get("value"))).message(value_item.get("message")));
					 }
					 else if(value_key.endsWith("Max")){
						 mapping.type(class_obj).property(key, ElementType.FIELD).constraint( new MaxDef().value(Integer.parseInt(value_item.get("value"))).message(value_item.get("message")));
					 }
					 else if(value_key.endsWith("NotNull")){
						 mapping.type(class_obj).property(key, ElementType.FIELD).constraint( new NotNullDef().message(value_item.get("message")));
					 }
					 config.addMapping( mapping );
				 }
			 }
		 }
		 return config;
	}
 
开发者ID:cfibmers,项目名称:open-Autoscaler,代码行数:30,代码来源:BeanValidation.java

示例15: run

import org.hibernate.validator.HibernateValidatorConfiguration; //导入方法依赖的package包/类
@Override
@Context
public void run(OdsConfig configuration, Environment environment) {
	Injector injector = Guice.createInjector(
			new MonitoringModule(environment.metrics()),
			new ConfigModule(configuration),
			new ProcessorModule(),
			new DbModule(configuration.getCouchDb()),
			new NotificationsModule(),
			new DataModule(),
			new AuthModule(configuration.getAuth()));

	// start data grabbing
	environment.lifecycle().manage(injector.getInstance(DataSourceManager.class));
	environment.jersey().getResourceConfig().register(MultiPartFeature.class);
	environment.jersey().getResourceConfig().register(injector.getInstance(AuthBinder.class));
	environment.jersey().register(injector.getInstance(DataSourceApi.class));
	environment.jersey().register(injector.getInstance(DataApi.class));
	environment.jersey().register(injector.getInstance(ProcessorChainApi.class));
	environment.jersey().register(injector.getInstance(DataViewApi.class));
	environment.jersey().register(injector.getInstance(NotificationApi.class));
	environment.jersey().register(injector.getInstance(PluginApi.class));
	environment.jersey().register(injector.getInstance(ProcessorSpecificationApi.class));
	environment.jersey().register(injector.getInstance(VersionApi.class));
	environment.jersey().register(injector.getInstance(UserApi.class));
	environment.jersey().register(PropertyFilteringMessageBodyWriter.class);
	environment.jersey().register(new DbExceptionMapper());
	environment.jersey().register(new JsonExceptionMapper());
	environment.jersey().register(new UnauthorizedExceptionMapper());
	environment.jersey().register(new NotFoundExceptionMapper());

	// setup users
	setupDefaultUsers(injector.getInstance(UserManager.class), configuration.getAuth().getUsers());

	// setup health checks
	environment.healthChecks().register(DbHealthCheck.class.getSimpleName(), injector.getInstance(DbHealthCheck.class));
	environment.healthChecks().register(PegelOnlineHealthCheck.class.getSimpleName(), injector.getInstance(PegelOnlineHealthCheck.class));
	environment.healthChecks().register(DataSourceHealthCheck.class.getSimpleName(), injector.getInstance(DataSourceHealthCheck.class));
	environment.healthChecks().register(FilterChainHealthCheck.class.getSimpleName(), injector.getInstance(FilterChainHealthCheck.class));
	environment.healthChecks().register(DataHealthCheck.class.getSimpleName(), injector.getInstance(DataHealthCheck.class));
	environment.healthChecks().register(CepsClientHealthCheck.class.getSimpleName(), injector.getInstance(CepsClientHealthCheck.class));

	// configure administration
	DropwizardResourceConfig jerseyConfig = new DropwizardResourceConfig(environment.metrics());
	JerseyContainerHolder jerseyContainerHolder = new JerseyContainerHolder(new ServletContainer(jerseyConfig));
	jerseyConfig.register(injector.getInstance(AdminFilterChainApi.class));
	environment.admin().addServlet("admin resources", jerseyContainerHolder.getContainer()).addMapping("/admin/*");

	// setup validation for external classes
	HibernateValidatorConfiguration validatorContext = Validation.byProvider(HibernateValidator.class).configure();
	ConstraintMapping mapping = validatorContext.createConstraintMapping();
	mapping.type(ProcessorReferenceChainDescription.class).constraint(new GenericConstraintDef<>(ValidChainReference.class));

	// setup Guice DI for hibernate validator
	environment.setValidator(validatorContext.addMapping(mapping)
			.constraintValidatorFactory(new GuiceConstraintValidatorFactory(injector))
			.buildValidatorFactory()
			.getValidator());
}
 
开发者ID:jvalue,项目名称:open-data-service,代码行数:60,代码来源:OdsApplication.java


注:本文中的org.hibernate.validator.HibernateValidatorConfiguration.createConstraintMapping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。