anyone can give me an advice for improving this piece code, it give me a complexity of score of 10. There is something telling in back of my mind that it can be improve, but this is the best i can do. arggg
public override bool Validate(Control control, object value)
{
if (value == null && !_IsAllowNull)
{
ErrorText = "Please provided valid number without a decimal point.";
return false;
}
else
{
if (value.ToString().Contains("."))
{
ErrorText = "Decimal value is not allowed";
return false;
}
else
{
if (!value.IsNumber())
{
ErrorText = "Please provided valid number without a decimal point.";
return false;
}
else
{
if (value.ToInt() < _minValue || value.ToInt() > _maxValue)
{
ErrorText = "Value should not be greater than " + _maxValue + " or less than " + _minValue;
return false;
}
}
}
}
return true;
}
I will appreciate for any help will come.