001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.validation;
018
019import org.apache.wicket.model.IModel;
020
021
022/**
023 * Interface representing any object that can be validated.
024 * 
025 * @author Igor Vaynberg (ivaynberg)
026 * @param <T>
027 *            type of value
028 * @since 1.2.6
029 */
030public interface IValidatable<T>
031{
032        /**
033         * Retrieves the value to be validated.
034         * 
035         * @return the value to be validated
036         */
037        T getValue();
038
039        /**
040         * Reports an error against this <code>IValidatable</code>'s value. Multiple errors can be
041         * reported by calling this method multiple times.
042         * 
043         * @param error
044         *            an <code>IValidationError</code> to be reported
045         */
046        void error(IValidationError error);
047
048        /**
049         * Queries the current state of this <code>IValidatable</code> instance.
050         * <code>IValidatable</code>s should assume they are valid until
051         * {@link #error(IValidationError)} is called.
052         * 
053         * @return <code>true</code> if the object is in a valid state, <code>false</code> if otherwise
054         */
055        boolean isValid();
056
057        /**
058         * Returns the model of the component being validated
059         * 
060         * @return component's model
061         */
062        IModel<T> getModel();
063}