Here is how I would write a validator for MaxValue
public class MaxValueAttribute : ValidationAttribute
{
private readonly int _maxValue;
public MaxValueAttribute(int maxValue)
{
_maxValue = maxValue;
}
public override bool IsValid(object value)
{
return (int) value <= _maxValue;
}
}
The MinValue Attribute should be fairly the same