1 /*
2 * Copyright 2006-2016 The JGUIraffe Team.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.jguiraffe.transform;
17
18 /**
19 * <p>
20 * Definition of a validator interface.
21 * </p>
22 * <p>
23 * Validators are objects that are able to check if given objects are valid.
24 * Often the objects to test have been obtained from user input. If validation
25 * passes on these objects, this means that the user has entered correct data.
26 * </p>
27 * <p>
28 * Implementing custom validators is very simple. There is only one main
29 * validation method that has to be implemented. This method is passed the
30 * object to be tested and can perform arbitrary actions to determine the
31 * validity of this object. A {@link TransformerContext} object
32 * is also passed, which can be used to obtain needed system information, e.g.
33 * the current locale.
34 * </p>
35 *
36 * @author Oliver Heger
37 * @version $Id: Validator.java 205 2012-01-29 18:29:57Z oheger $
38 */
39 public interface Validator
40 {
41 /**
42 * Validates the passed in object. The returned result object should contain
43 * all information about the validation: if the object is valid and error
44 * messages if this is not the case.
45 *
46 * @param o the object to test
47 * @param ctx the transformer context
48 * @return an object with the validation results
49 */
50 ValidationResult isValid(Object o, TransformerContext ctx);
51 }