Class ValidationService
java.lang.Object
fr.paris.lutece.portal.util.mvc.binding.validate.ValidationService
Service responsible for validating method parameters and return values
within the Lutece MVC framework using Jakarta Bean Validation (JSR-380).
This service integrates with the MVC binding mechanism to:
- If they are also annotated with
Valid, standard Jakarta validation constraints are applied. - If they are annotated with
Validated, validation is performed using the specified validation groups (group-based validation).
ExecutableValidator.
The service also formats localized error messages for user-friendly feedback.
It uses Validator and ExecutableValidator
for runtime validation of method arguments and return values.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvalidateParameters(Object resource, Method method, Object[] parameters) Validates the parameters of a controller method using Jakarta Bean Validation.voidvalidateReturnValue(Object resource, Method method, Object returnValue) Validates the return value of a controller method using Jakarta Bean Validation.
-
Constructor Details
-
ValidationService
public ValidationService()Default constructor.
-
-
Method Details
-
validateParameters
Validates the parameters of a controller method using Jakarta Bean Validation.This method performs validation on parameters annotated with
ModelAttribute. For those parameters:- If they are also annotated with
Valid, standard Jakarta validation constraints are applied. - If they are annotated with
Validated, validation is performed using the specified validation groups (group-based validation).
ExecutableValidator.- Parameters:
resource- The controller/resource instance on which the method is invoked.method- The method whose parameters are being validated.parameters- The parameter values passed to the method.
- If they are also annotated with
-
validateReturnValue
Validates the return value of a controller method using Jakarta Bean Validation.This method performs validation on the return value of a method annotated with
ValidatedorValid. It uses theExecutableValidatorto validate the return value against the method's constraints.- Parameters:
resource- The controller/resource instance on which the method is invoked.method- The method whose return value is being validated.returnValue- The return value of the method to validate.
-