Questions tagged [bean-validation]

0 votes
1 replies
Is there a validator to validate a list of Integers? private List<Integer> status;
I need to prevent XSS attacks using Spring validators. Is there an annotation for validating a list of Integers? @Digits(integer=1, fraction=...
asked 4 months ago
0 votes
0 replies
How to DI a Spring bean into a ConstraintValidator
I need to perform validation on a object by making use of a Spring repository. I'm trying to inject the Spring repo bean into the ConstraintValid...
0 votes
0 replies
Bean Validation with LocalValidatorFactoryBean
Is the following possible when using Spring's LocalValidatorFactoryBean? Application configuration: @Configuration @ComponentScan(basePackages...
0 votes
1 replies
How to keep the data on the form when submitted and invalid in spring boot
I have a form to handle password change. <form method="POST" th:object="${changePassword}" th:action="@{/user/change_pass}"> <input...
0 votes
2 replies
Micronaut - How to inject Hibernate validator
I am using the Hibernate validation mechanism in my Micronaut project as the documentation suggests. Unfortunately, I need to react to validatio...
asked 4 months ago
0 votes
1 replies
Validating objects integer property with hibernate validator
I want to validate attribute abc using hibernate validator to check if its null or not. class A { @NotNull private B meta; } class B { @NotNull...
2 votes
0 replies
Usages of AssertTrue.List (multipe AssertTrue)
I know the usages of AssertTrue, usually on methods (@AssertTrue), with optional message as: @AssertTrue(message="{specificDate.isDateTimeValid...
asked 5 months ago
0 votes
0 replies
Spring @Validated annotation prevents @ConfigurationProproperties value injection, why?
I am trying with @ConfigurationProperties and I find two things: for tests to work, I have to put configuration properties files (yml) in test...
1 votes
2 replies
Bean validation configuration not picked up if placed in library jar
I'm using Bean Validation 1.1 in a Java EE 7 web application. Validation works fine but I've trouble getting it to work on both Wildfly and Liber...
0 votes
1 replies
How can I validate primitive array elements?
I just found that @Size also works with primitive arrays. @Size(...) int[] A Is there any way to validate each element in A? Will following b...
asked 5 months ago
0 votes
2 replies
JSR-303 doesn't support such a scenario?
I try to validate beans by Hibernate Validator. It should be programable and based on a JSON config file. data models: class A { field,...
asked 6 months ago
1 votes
1 replies
JSR-303 bean validation - avoid bypassing a field
Suppose we have this bean public class Bean { @NotBlank(groups = {CheckForEmployee.class, CheckForAdmins.class}) private String sth1;...
0 votes
0 replies
Custom bean validator throws null pointer in unit test [duplicate]
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so...
0 votes
0 replies
validation-config in validation.xml support for properties
I've a validation.xml under META-INF folder. I want to use different constraint-mappings based on active spring profile. <?xml version="1.0"...
1 votes
2 replies
JSR-303 Shared Inherited Object Validation
suppose we have this structure: public class User { @NotNull(message = "not available") private String phoneNumber; //getter and setter...
asked 7 months ago
0 votes
0 replies
Consume response from JSR-303 validated Spring API?
I setup an API to validate, and have no issues there. My challenge is when calling that API and it fails validation. I don't know how to map the...
2 votes
0 replies
JSR 303 validation in Spring - how to refuse string of number when the field should only accept Integer
When I validate a JSON format entity in request body, a number field comes in as a string of number parsable to Integer is accepted as valid. But...
asked 7 months ago
1 votes
1 replies
Validation not working on spring boot and hibernate
I am new to spring boot and hibernate.I have declared a model class Office which is : package com.ashwin.officeproject.model; import com.fasterx...
2 votes
1 replies
Spring Custom Validator - Interpolate message with parameter
I've created a custom ConstraintValidator where the isValid method looks like this: private String message; @Override public void initialize(In...
1 votes
1 replies
javaee bean validation @NotNull not inheritable [duplicate]
This question already has an answer here: can I override a jsr-303 validation annotation...
asked 8 months ago
0 votes
0 replies
Use JpaRepository inside a ConstraintValidator object
I have Controler method receiving a email address from a form that an user can use if for example he lost his password or if he didn't received...
asked 7 months ago
0 votes
0 replies
Get java validation message outside the constraint
In java validation, it is possible to get the interpolated validation message from ValidationMessages.properties file using the ConstraintValidat...
0 votes
1 replies
how add custom validator for `javax.validation.constraints` annotation?
I have implemented validation for Long field and @PastOrPresent validation public class PastOrPresentValidator implements ConstraintValidator<...
0 votes
0 replies
Bean Validation: Parameterizing composed constraint
How to make composed constraint parameterized? For example, I want to use: public class Invoice { @ValidInvoiceAmount(100) private Big...
asked 6 months ago
0 votes
0 replies
How to do bean-backed validation on bootstrap modal form
I have been developing spring boot applications for a few years now but they have always been one-page-per-function kind of deal where i stayed a...