Questions tagged [spring-validator]

The Core package is the most fundamental part of the framework and provides the IoC and Dependency Injection features. The basic concept here is the BeanFactory, which provides a sophisticated implementation of the factory pattern which removes the need for programmatic singletons and allows you to decouple the configuration and specification of dependencies from your actual program logic.

The Context package build on the solid base provided by the Core package: it provides a way to access objects in a framework-style manner in a fashion somewhat reminiscent of a JNDI-registry. The context package inherits its features from the beans package and adds support for internationalization (I18N) (using for example resource bundles), event-propagation, resource-loading, and the transparent creation of contexts by, for example, a servlet container.

The DAO package provides a JDBC-abstraction layer that removes the need to do tedious JDBC coding and parsing of database-vendor specific error codes. Also, the JDBC package provides a way to do programmatic as well as declarative transaction management, not only for classes implementing special interfaces, but for all your POJOs (plain old Java objects).

The ORM package provides integration layers for popular object-relational mapping APIs, including JPA, JDO, Hibernate, and iBatis. Using the ORM package you can use all those O/R-mappers in combination with all the other features Spring offers, such as the simple declarative transaction management feature mentioned previously.

Spring's AOP package provides an AOP Alliance-compliant aspect-oriented programming implementation allowing you to define, for example, method-interceptors and pointcuts to cleanly decouple code implementing functionality that should logically speaking be separated. Using source-level metadata functionality you can also incorporate all kinds of behavioral information into your code, in a manner similar to that of .NET attributes.

Spring's Web package provides basic web-oriented integration features, such as multipart file-upload functionality, the initialization of the IoC container using servlet listeners and a web-oriented application context. When using Spring together with WebWork or Struts, this is the package to integrate with.

Spring's MVC package provides a Model-View-Controller (MVC) implementation for web-applications. Spring's MVC framework is not just any old implementation; it provides a clean separation between domain model code and web forms, and allows you to use all the other features of the Spring Framework.

338 questions
20
votes
4 answers

Spring-Data-Rest Validator

I have been trying to add spring validators to a spring-data-rest project. I followed along and setup the "getting started" application via this link: http://spring.io/guides/gs/accessing-data-rest/ ...and now I am trying to add a custom…
17
votes
1 answer

How can I programmatically call the same validator that runs on a @RequestMethod method with a @Valid parameter in Spring?

I have a class with hibernate's validation annotation on some fields (such as @NotNull and @Size(min = 4, max = 50), etc...) public class MyClass { Long id; @NotEmpty @Size(min = 4, max = 50) String machineName; @NotEmpty …
Daniel
  • 2,328
  • 3
  • 17
  • 31
12
votes
1 answer

javax.validation.constraints.Email matching invalid email address

I have a User entity having email property annotated with @Email @Email private String email; I am using @Valid (javax.validation.Valid) annotation on my Controller class. The issue is that the controller validator is passing the invalid emails.…
TheCoder
  • 2,157
  • 2
  • 25
  • 57
12
votes
4 answers

Spring Validate List of Strings for non empty elements

I have a model class which has list of Strings. The list can either be empty or have elements in it. If it has elements, those elements can not be empty. For an example suppose I have a class called QuestionPaper which has a list of questionIds each…
Ravindra Ranwala
  • 18,704
  • 6
  • 38
  • 55
11
votes
1 answer

Inject Repository inside ConstraintValidator with Spring 4 and message interpolation configuration

I created a small example project to show two problems I'm experiencing in the configuration of Spring Boot validation and its integration with Hibernate. I already tried other replies I found about the topic but unfortunately they didn't work for…
drenda
  • 4,771
  • 8
  • 50
  • 103
11
votes
1 answer

What does this nested annotation do / allow?

I was looking at the @org.hibernate.validator.constaints.NotEmpty annotation: @Documented @Constraint(validatedBy = { }) @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER…
Eric B.
  • 20,257
  • 43
  • 147
  • 269
8
votes
3 answers

Use @Validated and @Valid with spring validator

I have a java bean being used to send JSON messages to a spring @RestController and I have bean validation setup and running just fine using @Valid. But I want to move to Protobuf/Thrift and move away from REST. It is an internal API and a lot of…
sbzoom
  • 2,977
  • 4
  • 25
  • 31
7
votes
4 answers

Spring Web MVC validation by Hibernate Validator doesn't draw Errors in BindingResult

I've been using Hibernate Validator in my Spring project. I'm about to validate my JUser Object automatically. i.e, I want Spring to validate the Object and set errors in BindigResult. But It doesn't work. pom.xml
7
votes
2 answers

Spring REST - validating primitive GET request parameters

Is there a way to validate primitive (int, String etc.) GET parameters using annotations? @RequestMapping(value = "/api/{someInt}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) public ResponseEntity
uylmz
  • 1,374
  • 1
  • 20
  • 35
7
votes
1 answer

Spring validation for list of nested class

I have implemented my validation for list of custom class as mention in this post. For reference here my code looks like class TopDtoForm { @NotEmpty private String topVar; private List downVarList; //getter and setter } class…
αƞjiβ
  • 2,626
  • 9
  • 51
  • 87
6
votes
2 answers

@Valid @CustomValidator inside a spring @Service

I used to validate my beans inside my spring @RestController like: @PostMapping("/documents") @ResponseStatus(HttpStatus.CREATED) fun create(@Valid @RequestBody document: DocumentCreate) { return documentService.create(document) } Even it seems…
6
votes
2 answers

Spring JPA doesn't validate bean on update

I'm using Spring Boot 1.5.7, Spring JPA, Hibernate validation, Spring Data REST, Spring HATEOAS. I've a simple bean like this: @Entity public class Person { @Id @GeneratedValue private Long id; @NotBlank private String…
drenda
  • 4,771
  • 8
  • 50
  • 103
6
votes
3 answers

How to: Spring get rid of @Validate for automatic Controller validation?

I know about @Valid annotation to instruct spring to validate for example a Controller argument according to JSR-303 in such this example: @GetMapping("/test") public TestDTO testDTO(@Valid TestDTO testDTO){ return testDTO; } But I would…
6
votes
1 answer

Spring 4 MVC Validation not working - BindingResult hasErrors is false

I am unit testing a Spring controllers post method (using org.springframework.test.web.servlet.MockMvc), and I'm trying to confirm that when there are validation errors in the form it will send the view back to the form by checking the…
PDStat
  • 4,661
  • 9
  • 41
  • 75
5
votes
3 answers

From Spring BindingResult to field JSONPath/JSON Pointer, with Jackson

I have a Spring Boot application using javax.validation annotations and I'm trying to return friendly JSON error messages pointing to the offending field, yet converting from the available "Java-object" path to either JSONPath or JSON Pointer is…
mdrg
  • 3,095
  • 2
  • 20
  • 42
1
2 3
22 23