Questions tagged [bean-validation]

Bean Validation, previously commonly called just "JSR-303", is an annotation based validation framework for javabean properties and parameters of arbitrary methods. Hibernate Validator is the reference implementation and the most widely used one.

Online resources

1913 questions
0
votes
0 answers

Method level constraint validator not executed

I'm doing validation at my Spring REST Controller class. My custom constraint validator is not executed, if constraint violation happens to the argument object itself. Expectation Request: { fieldA: "2020-01-05", fieldB: "2020-01-02", fieldC:…
chunhoong
  • 105
  • 1
  • 10
0
votes
1 answer

spring security login: Validating input

I am looking for a sound method of performing input validation for the user credentials on login. Specifically - that the username conforms to some size limit: if provided value is too big, fail fast, instead of passing it through to the…
pointyhat
  • 568
  • 5
  • 16
0
votes
1 answer

Java Bean Validation 2.0 Hibernate Validator - Executable JAR with external XML-Configuration

Context I'm developing a stand-alone application that reads input-data from a csv-file. Until now I've used a self-written class to perform input validation, and the method used for validating a single record from the input file was triggered…
0
votes
1 answer

Hibernate validator executing JAX-RS REST end point even on constraint violation

I am using Hibernate validator 5.x and javax validation 1.x(due to some reasons, can not upgrade). This scenario works in hibernate validator 6.x and validation 2.x On constraint violation, Validator kicks in and shows proper error response, But at…
Arfat Binkileb
  • 641
  • 4
  • 18
0
votes
0 answers

Override field validation

I have a problem: public class hello{ protected String xx; @NotEmpty @JsonProperty("xx") @JacksonXmlProperty(localName = "xx") public String getXx() { return xx; } public void setxx(String xx) { this.xx=…
Xavi Guirao
  • 338
  • 4
  • 17
0
votes
0 answers

How to determine which parameter caused the HttpMessageNotReadableException during bean validation

For the Page Number if someone has entered "test" , I want to customise the error message "Please provide the correct type for the parameter : pageNo". Request Object: { "pageSize":6, "pageNo":"test", "sortBy":…
Karthik Suresh
  • 367
  • 7
  • 23
0
votes
2 answers

JSR 303 validation with hierarchy

Supose we have an object that extends another and I want to create a custom validation for both, example: Period and PeriodAmount objects. Where Period is: public class Period { private LocalDate startDate; private LocalDate endDate; And…
jfajunior
  • 1,211
  • 1
  • 15
  • 19
0
votes
1 answer

Conditional validation on request fields in spring boot

I just started with the field validation of request body and have all the basic annotated validations implemented. I have a field validation dependent on other field. This class is being used a request body. Validation condition: If…
Randhev
  • 1
  • 1
  • 3
0
votes
1 answer

Is it possible to create multiple custom validation message for @Valid argument exception?

I want to create custom message for my custom validation annotation. If this validation failed, it throws MethodArgumentNotValidException. Because I put @Valid for the @RequestBody. I create @ControllerAdvice to handle/ override…
chronos14
  • 321
  • 1
  • 5
  • 20
0
votes
1 answer

How to get the value of the @Size annotation, above the field of object

I need to pull over the field the attribute value from the @Size annotation private static int getMaxLimitSize(Field field){ field.setAccessible(true); Size annotation = field.getAnnotation(Size.class); int zero = 0; if(annotation…
skyho
  • 1,438
  • 2
  • 20
  • 47
0
votes
1 answer

jsonchema2pojo: How the minLength, maxLength bounds applied on generated Java Pojo class?

I want to know, how the bounds provided in JSON schema gets transformed in to java POJO class? For example, below is definitions.json file contents - { "definitions": { "address": { "type": "object", "properties": { …
Gunwant
  • 949
  • 1
  • 14
  • 29
0
votes
2 answers

Spring Boot : How to do REST validation based on input group?

I have a form in which : firstname and lastname are mandatory fields for registered user. ssn for new user. contract number for owner. So, on clicking the submit button, REST API (connect API) is called with values from either of the above…
Nidhya
  • 1
  • 1
0
votes
1 answer

@Transient attribute that generate a ConstraintViolationException

This is my Class @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Email @NotEmpty private String email; @NotEmpty private String password; @Transient …
xmen-5
  • 1,806
  • 1
  • 23
  • 44
0
votes
1 answer

How to do JSR-303 constraint validation at field level based on the condition selected

I have a form with many fields i.e single and joint applications. Based on the radio button I need to validate these fields . If I choose yes in radio button then single and joint fields has to be vaidated and if I choose no then single alone…
Pradeep
  • 1,947
  • 3
  • 22
  • 45
0
votes
2 answers

getting NoSuchMethodError from javax.validation library on deployment

As per the documentation, I should be able to serve my static js content by adding the tag to my servlet.xml file. I feel I am implementing my servlet.xml file correctly, but I am receiving errors related to bean validation after…
plum 0
  • 652
  • 9
  • 21