diff --git a/spring-context/src/main/java/org/springframework/validation/SmartValidator.java b/spring-context/src/main/java/org/springframework/validation/SmartValidator.java index 36ad9f588d..c033a9266d 100644 --- a/spring-context/src/main/java/org/springframework/validation/SmartValidator.java +++ b/spring-context/src/main/java/org/springframework/validation/SmartValidator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,4 +64,19 @@ public interface SmartValidator extends Validator { throw new IllegalArgumentException("Cannot validate individual value for " + targetType); } + /** + * Return a contained validator instance of the specified type, unwrapping + * as far as necessary. + * @param type the class of the object to return + * @param the type of the object to return + * @return a validator instance of the specified type; {@code null} if there + * isn't a nested validator; an exception may be raised if the specified + * validator type does not match. + * @since 6.1 + */ + @Nullable + default T unwrap(@Nullable Class type) { + return null; + } + }