// $Id$ // // Copyright 2007-2008 Cisco Systems Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. using System; namespace Etch.Msg { /// /// Validate values put into messages /// abstract public class Validator { /// /// The validation level. /// public enum Level { /// /// No validation on put or output. /// NONE, /// /// Validation on put or output if validator defined. /// MISSIN_OK, /// /// Like MISSING_OK, but fail if no validator defined. /// FULL } /// /// The maximum number of dimensions for arrays /// public const int MAX_NDIMS = 9; /// /// The maximum number of validators to cache per type. /// protected const int MAX_CACHED = 4; /// /// /// /// for an array type, return a validator for an element of /// the array (which might be a scalar or another array element). abstract public Validator ElementValidator(); /// /// Checks the value for being valid. If the value is valid /// by this validator, return true. /// /// the value to be validated. /// true if the value is valid by any validator in the /// chain, or false if all reject it. abstract public bool Validate( Object value ); /// /// /// /// return the appropriate value given the input value and this /// validator's sensibility about what it should be really (e.g., /// input Byte but output Long. abstract public Object ValidateValue(Object value); } }