001/*
002 * Copyright 2002-2012 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.validation;
018
019/**
020 * Extended variant of the {@link Validator} interface, adding support for
021 * validation 'hints'.
022 *
023 * @author Juergen Hoeller
024 * @author Sam Brannen
025 * @since 3.1
026 */
027public interface SmartValidator extends Validator {
028
029        /**
030         * Validate the supplied {@code target} object, which must be of a type of {@link Class}
031         * for which the {@link #supports(Class)} method typically returns {@code true}.
032         * <p>The supplied {@link Errors errors} instance can be used to report any
033         * resulting validation errors.
034         * <p><b>This variant of {@code validate()} supports validation hints, such as
035         * validation groups against a JSR-303 provider</b> (in which case, the provided hint
036         * objects need to be annotation arguments of type {@code Class}).
037         * <p>Note: Validation hints may get ignored by the actual target {@code Validator},
038         * in which case this method should behave just like its regular
039         * {@link #validate(Object, Errors)} sibling.
040         * @param target the object that is to be validated (can be {@code null})
041         * @param errors contextual state about the validation process (never {@code null})
042         * @param validationHints one or more hint objects to be passed to the validation engine
043         * @see ValidationUtils
044         */
045        void validate(Object target, Errors errors, Object... validationHints);
046
047}