Class RangeAttribute
A range constraint validator.
Implements
Namespace: Swan.Validators
Syntax
public class RangeAttribute : Attribute, IValidator
  Constructors
RangeAttribute(Double, Double)
Initializes a new instance of the RangeAttribute class. Constructor that takes double minimum and maximum values.
Declaration
public RangeAttribute(double min, double max)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Double | min | The minimum value.  | 
      
| Double | max | The maximum value.  | 
      
RangeAttribute(Int32, Int32)
Initializes a new instance of the RangeAttribute class. Constructor that takes integer minimum and maximum values.
Declaration
public RangeAttribute(int min, int max)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Int32 | min | The minimum value.  | 
      
| Int32 | max | The maximum value.  | 
      
Properties
ErrorMessage
The error message.
Declaration
public string ErrorMessage { get; }
  Property Value
| Type | Description | 
|---|---|
| String | 
Maximum
Maximum value for the range.
Declaration
public IComparable Maximum { get; }
  Property Value
| Type | Description | 
|---|---|
| IComparable | 
Minimum
Minimum value for the range.
Declaration
public IComparable Minimum { get; }
  Property Value
| Type | Description | 
|---|---|
| IComparable | 
Methods
IsValid<T>(T)
Checks if a value is valid.
Declaration
public bool IsValid<T>(T value)
  Parameters
| Type | Name | Description | 
|---|---|---|
| T | value | The value.  | 
      
Returns
| Type | Description | 
|---|---|
| Boolean | True if it is valid.False if it is not.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The type.  |