Class CompareToAttribute
- Namespace
 - Acuit.Pinpoint.Common.Validation
 
- Assembly
 - Acuit.Pinpoint.Common.dll
 
Used for specifying a compare-to validation constraint.
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Parameter, AllowMultiple = false)]
public abstract class CompareToAttribute : ValidationAttribute, _Attribute
  - Inheritance
 - 
      
      
      
      CompareToAttribute
 
- Implements
 
- Derived
 
- Inherited Members
 
Constructors
CompareToAttribute(Type, object, bool, bool, bool)
Initializes a new instance of the CompareToAttribute class.
protected CompareToAttribute(Type operandType, object comparisonValue, bool allowLessThan, bool allowEqualTo, bool allowGreaterThan)
  Parameters
operandTypeTypeThe type of the range parameters. Must implement IComparable.
comparisonValueobjectThe comparison value.
allowLessThanboolWhether to allow values less than
comparisonValue.allowEqualToboolWhether to allow values equal to
comparisonValue.allowGreaterThanboolWhether to allow values greater than
comparisonValue.
CompareToAttribute(Type, object, bool, bool, bool, Func<string>)
Initializes a new instance of the CompareToAttribute class.
protected CompareToAttribute(Type operandType, object comparisonValue, bool allowLessThan, bool allowEqualTo, bool allowGreaterThan, Func<string> errorMessageAccessor)
  Parameters
operandTypeTypeThe type of the range parameters. Must implement IComparable.
comparisonValueobjectThe comparison value.
allowLessThanboolWhether to allow values less than
comparisonValue.allowEqualToboolWhether to allow values equal to
comparisonValue.allowGreaterThanboolWhether to allow values greater than
comparisonValue.errorMessageAccessorFunc<string>The Func<TResult> that will return an error message.
CompareToAttribute(Type, object, bool, bool, bool, string)
Initializes a new instance of the CompareToAttribute class.
protected CompareToAttribute(Type operandType, object comparisonValue, bool allowLessThan, bool allowEqualTo, bool allowGreaterThan, string errorMessage)
  Parameters
operandTypeTypeThe type of the range parameters. Must implement IComparable.
comparisonValueobjectThe comparison value.
allowLessThanboolWhether to allow values less than
comparisonValue.allowEqualToboolWhether to allow values equal to
comparisonValue.allowGreaterThanboolWhether to allow values greater than
comparisonValue.errorMessagestringA non-localized error message to use.
Properties
AllowEqualTo
Gets whether equal-to comparisons are considered valid.
public bool AllowEqualTo { get; }
  Property Value
AllowGreaterThan
Gets whether greater-than comparisons are considered valid.
public bool AllowGreaterThan { get; }
  Property Value
AllowLessThan
Gets whether less-than comparisons are considered valid.
public bool AllowLessThan { get; }
  Property Value
ComparisonValue
Gets the value for comparison.
public object ComparisonValue { get; }
  Property Value
OperandType
Gets the type of the ComparisonValue value (e.g. int, double, or some custom type).
public Type OperandType { get; }
  Property Value
Methods
FormatErrorMessage(string)
Applies formatting to an error message, based on the data field where the error occurred.
public override string FormatErrorMessage(string name)
  Parameters
namestringThe name to include in the formatted message.
Returns
- string
 An instance of the formatted error message.
IsValid(object)
Checks whether the specified object is valid.
public override bool IsValid(object value)
  Parameters
valueobjectThe value of the object to validate.