本文整理汇总了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;
}
示例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;
}
示例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);
}
示例7: initBinder
import org.springframework.validation.beanvalidation.SpringValidatorAdapter; //导入依赖的package包/类
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setValidator(new SpringValidatorAdapter(messageValidator));
}
示例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);
}