I have a column inside my sql server 2008 wih type of Decimal(18,2). But on entity framework what is the best data annotation validation I can apply to this pro
I think @jumpingcode's answer can be combined into one RegularExpressionAttribute.
[RegularExpression(@"^(0|-?\d{0,16}(\.\d{0,2})?)$")]
public decimal Property
{
get;
set;
}
This can be used for any precision and scale. The 16 is replaced by precision - scale and the 2 is replaced by the scale. The regular expression should match numbers entered like ###, 0.##, .##, 0, and ###.## as well as negative values.