1 /* 2 * Copyright 1999-2004 The Apache Software Foundation. 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 org.apache.cocoon.woody.datatype; 17 18 import org.outerj.expression.ExpressionContext; 19 20 /** 21 * Interface for validation rules. Most {@link Datatype} implementations will 22 * perform their validation by checking a number of these validation rules 23 * (though strictly spoken this is not required). 24 * 25 * @version $Id: ValidationRule.java 30932 2004-07-29 17:35:38Z vgritsenko $ 26 */ 27 public interface ValidationRule { 28 /** 29 * 30 * @param value a value of a class supported by the ValidationRule implementation 31 * @param expressionContext many validation rules use the xReporter expression interpreter, 32 * the expressionContext allows to resolve variables used in these expressions. 33 */ 34 ValidationError validate(Object value, ExpressionContext expressionContext); 35 36 /** 37 * Returns true if this ValidationRule supports validating objects of the same class 38 * as the one specified. If the flag 'arrayType' is true, this method will return true 39 * if this validation rule can validate arrays of these objects (i.e. the object passed 40 * to the validate method will then be an array). 41 */ 42 boolean supportsType(Class clazz, boolean arrayType); 43 } 44