Java 类org.springframework.validation.beanvalidation.SpringValidatorAdapter 实例源码

项目:chassis    文件:RawWebSocketMessage.java   
/**
 * 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;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertiesConfigurationFactoryTests.java   
@Test
public void testValidationErrorCanBeSuppressed() throws Exception {
    this.validator = new SpringValidatorAdapter(
            Validation.buildDefaultValidatorFactory().getValidator());
    setupFactory();
    this.factory.setExceptionIfInvalid(false);
    bindFoo("bar: blah");
}
项目:spring-boot-concourse    文件:PropertiesConfigurationFactoryTests.java   
@Test
public void testValidationErrorCanBeSuppressed() throws Exception {
    this.validator = new SpringValidatorAdapter(
            Validation.buildDefaultValidatorFactory().getValidator());
    setupFactory();
    this.factory.setExceptionIfInvalid(false);
    bindFoo("bar: blah");
}
项目:contestparser    文件:PropertiesConfigurationFactoryTests.java   
@Test
public void testValidationErrorCanBeSuppressed() throws Exception {
    this.validator = new SpringValidatorAdapter(
            Validation.buildDefaultValidatorFactory().getValidator());
    setupFactory();
    this.factory.setExceptionIfInvalid(false);
    bindFoo("bar: blah");
}
项目:spring-greenhouse-clickstart    文件:SignupController.java   
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;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertiesConfigurationFactoryTests.java   
@Test(expected = BindException.class)
public void testMissingPropertyCausesValidationError() throws Exception {
    this.validator = new SpringValidatorAdapter(
            Validation.buildDefaultValidatorFactory().getValidator());
    createFoo("bar: blah");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:YamlConfigurationFactoryTests.java   
@Test(expected = BindException.class)
public void missingPropertyCausesValidationError() throws Exception {
    this.validator = new SpringValidatorAdapter(
            Validation.buildDefaultValidatorFactory().getValidator());
    createFoo("bar: blah");
}
项目:spring-boot-concourse    文件:PropertiesConfigurationFactoryTests.java   
@Test(expected = BindException.class)
public void testMissingPropertyCausesValidationError() throws Exception {
    this.validator = new SpringValidatorAdapter(
            Validation.buildDefaultValidatorFactory().getValidator());
    createFoo("bar: blah");
}
项目:spring-boot-concourse    文件:YamlConfigurationFactoryTests.java   
@Test(expected = BindException.class)
public void missingPropertyCausesValidationError() throws Exception {
    this.validator = new SpringValidatorAdapter(
            Validation.buildDefaultValidatorFactory().getValidator());
    createFoo("bar: blah");
}
项目:contestparser    文件:PropertiesConfigurationFactoryTests.java   
@Test(expected = BindException.class)
public void testMissingPropertyCausesValidationError() throws Exception {
    this.validator = new SpringValidatorAdapter(
            Validation.buildDefaultValidatorFactory().getValidator());
    createFoo("bar: blah");
}
项目:contestparser    文件:YamlConfigurationFactoryTests.java   
@Test(expected = BindException.class)
public void missingPropertyCausesValidationError() throws Exception {
    this.validator = new SpringValidatorAdapter(
            Validation.buildDefaultValidatorFactory().getValidator());
    createFoo("bar: blah");
}
项目:onetwo    文件:ValidatorWrapper.java   
private ValidatorWrapper(Validator validator) {
    super();
    this.validator = validator;
    this.adapter = new SpringValidatorAdapter(validator);
}
项目:chassis    文件:HttpValidator.java   
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.setValidator(new SpringValidatorAdapter(messageValidator));
}
项目:spring-scaffy    文件:CustomValidator.java   
/**
 * <p>Constructor for CustomValidator.</p>
 *
 * @param validator a {@link javax.validation.Validator} object.
 */
public CustomValidator(javax.validation.Validator validator) {
    this.springValidator = new SpringValidatorAdapter(validator);
}