@@ -287,32 +287,7 @@ As the preceding example shows, a `ConstraintValidator` implementation can have
287
287
You can integrate the method validation feature of Bean Validation into a
288
288
Spring context through a `MethodValidationPostProcessor` bean definition:
289
289
290
- [tabs]
291
- ======
292
- Java::
293
- +
294
- [source,java,indent=0,subs="verbatim,quotes",role="primary"]
295
- ----
296
- import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
297
-
298
- @Configuration
299
- public class AppConfig {
300
-
301
- @Bean
302
- public static MethodValidationPostProcessor validationPostProcessor() {
303
- return new MethodValidationPostProcessor();
304
- }
305
- }
306
-
307
- ----
308
-
309
- XML::
310
- +
311
- [source,xml,indent=0,subs="verbatim,quotes",role="secondary"]
312
- ----
313
- <bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor"/>
314
- ----
315
- ======
290
+ include-code::./ApplicationConfiguration[tag=snippet,indent=0]
316
291
317
292
To be eligible for Spring-driven method validation, target classes need to be annotated
318
293
with Spring's `@Validated` annotation, which can optionally also declare the validation
@@ -345,36 +320,7 @@ By default, `jakarta.validation.ConstraintViolationException` is raised with the
345
320
you can have `MethodValidationException` raised instead with ``ConstraintViolation``s
346
321
adapted to `MessageSourceResolvable` errors. To enable set the following flag:
347
322
348
- [tabs]
349
- ======
350
- Java::
351
- +
352
- [source,java,indent=0,subs="verbatim,quotes",role="primary"]
353
- ----
354
- import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
355
-
356
- @Configuration
357
- public class AppConfig {
358
-
359
- @Bean
360
- public static MethodValidationPostProcessor validationPostProcessor() {
361
- MethodValidationPostProcessor processor = new MethodValidationPostProcessor();
362
- processor.setAdaptConstraintViolations(true);
363
- return processor;
364
- }
365
- }
366
-
367
- ----
368
-
369
- XML::
370
- +
371
- [source,xml,indent=0,subs="verbatim,quotes",role="secondary"]
372
- ----
373
- <bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor">
374
- <property name="adaptConstraintViolations" value="true"/>
375
- </bean>
376
- ----
377
- ======
323
+ include-code::./ApplicationConfiguration[tag=snippet,indent=0]
378
324
379
325
`MethodValidationException` contains a list of ``ParameterValidationResult``s which
380
326
group errors by method parameter, and each exposes a `MethodParameter`, the argument
0 commit comments