Table of Contents

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

operandType Type

The type of the range parameters. Must implement IComparable.

comparisonValue object

The comparison value.

allowLessThan bool

Whether to allow values less than comparisonValue.

allowEqualTo bool

Whether to allow values equal to comparisonValue.

allowGreaterThan bool

Whether 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

operandType Type

The type of the range parameters. Must implement IComparable.

comparisonValue object

The comparison value.

allowLessThan bool

Whether to allow values less than comparisonValue.

allowEqualTo bool

Whether to allow values equal to comparisonValue.

allowGreaterThan bool

Whether to allow values greater than comparisonValue.

errorMessageAccessor Func<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

operandType Type

The type of the range parameters. Must implement IComparable.

comparisonValue object

The comparison value.

allowLessThan bool

Whether to allow values less than comparisonValue.

allowEqualTo bool

Whether to allow values equal to comparisonValue.

allowGreaterThan bool

Whether to allow values greater than comparisonValue.

errorMessage string

A non-localized error message to use.

Properties

AllowEqualTo

Gets whether equal-to comparisons are considered valid.

public bool AllowEqualTo { get; }

Property Value

bool

AllowGreaterThan

Gets whether greater-than comparisons are considered valid.

public bool AllowGreaterThan { get; }

Property Value

bool

AllowLessThan

Gets whether less-than comparisons are considered valid.

public bool AllowLessThan { get; }

Property Value

bool

ComparisonValue

Gets the value for comparison.

public object ComparisonValue { get; }

Property Value

object

OperandType

Gets the type of the ComparisonValue value (e.g. int, double, or some custom type).

public Type OperandType { get; }

Property Value

Type

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

name string

The 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

value object

The value of the object to validate.

Returns

bool

true if the specified value is valid; otherwise, false.