Can JSR 303 Bean Validation be used with Spring Data Rest?

Marcel Overdijk

I understand from the docs http://docs.spring.io/spring-data/rest/docs/2.1.2.RELEASE/reference/html/validation-chapter.html that I can declare validators with certain prefixes.

I'm using JSR 303 so my domain entities are annotated with validation annotations.

Can - and if yes, how - I use JSR 303 Bean Validation with Spring Data Rest?

PS: I'm using Spring Boot

Marcel Overdijk

This seems to work:

@Configuration
protected static class CustomRepositoryRestMvcConfiguration extends RepositoryRestMvcConfiguration {

    @Autowired
    private Validator validator;

    @Override
    protected void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener validatingListener) {
        validatingListener.addValidator("beforeCreate", validator);
        validatingListener.addValidator("beforeSave", validator);
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

kotlin data class + bean validation jsr 303

From Dev

Spring JSR-303 bean validation not working, empty bindingresult

From Dev

Spring + JSF2 + JSR 303 bean validation

From Dev

BindingResult not working in Spring 3.2.8 using JSR-303 BEAN VALIDATION

From Dev

JSR-303 Bean Validation Collection Values

From Dev

bean validation (JSR 303) for primefaces not working

From Dev

Spring Data REST Bean Validation

From Dev

Nested validation groups, Spring, JSR 303

From Dev

JSR 303 bean validation unit testing with Mockito and Autowiring

From Dev

Wildfly: ExceptionMapper not triggered with RestEasy JSR-303 Bean Validation

From Dev

JSR303 validation doesn't validate if @Id is not @GeneratedValue with Spring Data Jpa and Hibernate

From Dev

Spring MVC: use different JSR-303 validators on the same bean?

From Dev

Spring MVC: use different JSR-303 validators on the same bean?

From Dev

Spring mvc controller jsr 303 basic list validation

From Dev

Spring mvc controller jsr 303 basic list validation

From Dev

spring boot jsr 303 validation with nested array path fails

From Dev

Can JSR-349 Bean Validation Annotations be Used to Validate Java Time Types?

From Dev

How to break coupling between bean and validator with Bean Validation (JSR303)?

From Dev

Custom Bean Validator -- JSR303/JSR349 can Validator choose message when invalid?

From Dev

Is EclipseLink MOXy capable of applying JSR-303 Bean Validation when unmarshalling XML to object?

From Dev

Is EclipseLink MOXy capable of applying JSR-303 Bean Validation when unmarshalling XML to object?

From Dev

JSR - 349 bean validation for Spring @RestController with Spring Boot

From Dev

Implementing custom validation logic for a spring boot endpoint using a combination of JSR-303 and Spring's Validator

From Dev

Implementing custom validation logic for a spring boot endpoint using a combination of JSR-303 and Spring's Validator

From Dev

Consistent JSR-303 validation with optional properties in Spring controllers and Spring webflow?

From Dev

Exception while binidng form to bean using Spring MVC, JSR 303 Annotation

From Dev

Spring Boot JSR-303/349 configuration

From Dev

Can MongoDBs full text search be used with Spring Data REST?

From Dev

How to implement multiple JSR-303 validation messages for the same @Constraint?

Related Related

  1. 1

    kotlin data class + bean validation jsr 303

  2. 2

    Spring JSR-303 bean validation not working, empty bindingresult

  3. 3

    Spring + JSF2 + JSR 303 bean validation

  4. 4

    BindingResult not working in Spring 3.2.8 using JSR-303 BEAN VALIDATION

  5. 5

    JSR-303 Bean Validation Collection Values

  6. 6

    bean validation (JSR 303) for primefaces not working

  7. 7

    Spring Data REST Bean Validation

  8. 8

    Nested validation groups, Spring, JSR 303

  9. 9

    JSR 303 bean validation unit testing with Mockito and Autowiring

  10. 10

    Wildfly: ExceptionMapper not triggered with RestEasy JSR-303 Bean Validation

  11. 11

    JSR303 validation doesn't validate if @Id is not @GeneratedValue with Spring Data Jpa and Hibernate

  12. 12

    Spring MVC: use different JSR-303 validators on the same bean?

  13. 13

    Spring MVC: use different JSR-303 validators on the same bean?

  14. 14

    Spring mvc controller jsr 303 basic list validation

  15. 15

    Spring mvc controller jsr 303 basic list validation

  16. 16

    spring boot jsr 303 validation with nested array path fails

  17. 17

    Can JSR-349 Bean Validation Annotations be Used to Validate Java Time Types?

  18. 18

    How to break coupling between bean and validator with Bean Validation (JSR303)?

  19. 19

    Custom Bean Validator -- JSR303/JSR349 can Validator choose message when invalid?

  20. 20

    Is EclipseLink MOXy capable of applying JSR-303 Bean Validation when unmarshalling XML to object?

  21. 21

    Is EclipseLink MOXy capable of applying JSR-303 Bean Validation when unmarshalling XML to object?

  22. 22

    JSR - 349 bean validation for Spring @RestController with Spring Boot

  23. 23

    Implementing custom validation logic for a spring boot endpoint using a combination of JSR-303 and Spring's Validator

  24. 24

    Implementing custom validation logic for a spring boot endpoint using a combination of JSR-303 and Spring's Validator

  25. 25

    Consistent JSR-303 validation with optional properties in Spring controllers and Spring webflow?

  26. 26

    Exception while binidng form to bean using Spring MVC, JSR 303 Annotation

  27. 27

    Spring Boot JSR-303/349 configuration

  28. 28

    Can MongoDBs full text search be used with Spring Data REST?

  29. 29

    How to implement multiple JSR-303 validation messages for the same @Constraint?

HotTag

Archive