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


Java SpringValidatorAdapter类代码示例

本文整理汇总了Java中org.springframework.validation.beanvalidation.SpringValidatorAdapter的典型用法代码示例。如果您正苦于以下问题:Java SpringValidatorAdapter类的具体用法?Java SpringValidatorAdapter怎么用?Java SpringValidatorAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: deserialize

import org.springframework.validation.beanvalidation.SpringValidatorAdapter; //导入依赖的package包/类
/**
 * Deserializes the given message.
 * 
 * @param action
 * @return
 * @throws Exception
 */
public T deserialize(WebSocketAction action) throws Exception {
	// first deserialize
	T message = null;
	
	if (messageClass != null) {
		message = serDe.deserialize(new ByteBufferBackedInputStream(rawData), messageClass);
	}
	
	// then validate
	if (message != null && action.shouldValidatePayload()) {
		SpringValidatorAdapter validatorAdapter = new SpringValidatorAdapter(messageValidator);
		
		BeanPropertyBindingResult result = new BeanPropertyBindingResult(message, messageClass.getName());
		
		validatorAdapter.validate(message, result);
		
		if (result.hasErrors()) {
			throw new MethodArgumentNotValidException(new MethodParameter(action.getMethod(), action.getPayloadParameterIndex()), result);
		}
	}
	
	return message;
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:31,代码来源:RawWebSocketMessage.java

示例2: testValidationErrorCanBeSuppressed

import org.springframework.validation.beanvalidation.SpringValidatorAdapter; //导入依赖的package包/类
@Test
public void testValidationErrorCanBeSuppressed() throws Exception {
	this.validator = new SpringValidatorAdapter(
			Validation.buildDefaultValidatorFactory().getValidator());
	setupFactory();
	this.factory.setExceptionIfInvalid(false);
	bindFoo("bar: blah");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:PropertiesConfigurationFactoryTests.java

示例3: validate

import org.springframework.validation.beanvalidation.SpringValidatorAdapter; //导入依赖的package包/类
private BindException validate(SignupForm form) {
	BindException errors;
	errors = new BindException(form, "signupForm");
	LazyValidatorFactory lvf = new LazyValidatorFactory();
	Validator validator = new SpringValidatorAdapter(lvf.getValidator());
	ValidationUtils.invokeValidator(validator, form, errors);
	return errors;
}
 
开发者ID:mqprichard,项目名称:spring-greenhouse-clickstart,代码行数:9,代码来源:SignupController.java

示例4: testMissingPropertyCausesValidationError

import org.springframework.validation.beanvalidation.SpringValidatorAdapter; //导入依赖的package包/类
@Test(expected = BindException.class)
public void testMissingPropertyCausesValidationError() throws Exception {
	this.validator = new SpringValidatorAdapter(
			Validation.buildDefaultValidatorFactory().getValidator());
	createFoo("bar: blah");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:PropertiesConfigurationFactoryTests.java

示例5: missingPropertyCausesValidationError

import org.springframework.validation.beanvalidation.SpringValidatorAdapter; //导入依赖的package包/类
@Test(expected = BindException.class)
public void missingPropertyCausesValidationError() throws Exception {
	this.validator = new SpringValidatorAdapter(
			Validation.buildDefaultValidatorFactory().getValidator());
	createFoo("bar: blah");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:YamlConfigurationFactoryTests.java

示例6: ValidatorWrapper

import org.springframework.validation.beanvalidation.SpringValidatorAdapter; //导入依赖的package包/类
private ValidatorWrapper(Validator validator) {
	super();
	this.validator = validator;
	this.adapter = new SpringValidatorAdapter(validator);
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:6,代码来源:ValidatorWrapper.java

示例7: initBinder

import org.springframework.validation.beanvalidation.SpringValidatorAdapter; //导入依赖的package包/类
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.setValidator(new SpringValidatorAdapter(messageValidator));
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:5,代码来源:HttpValidator.java

示例8: CustomValidator

import org.springframework.validation.beanvalidation.SpringValidatorAdapter; //导入依赖的package包/类
/**
 * <p>Constructor for CustomValidator.</p>
 *
 * @param validator a {@link javax.validation.Validator} object.
 */
public CustomValidator(javax.validation.Validator validator) {
	this.springValidator = new SpringValidatorAdapter(validator);
}
 
开发者ID:mcraken,项目名称:spring-scaffy,代码行数:9,代码来源:CustomValidator.java


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