How do I accept 0 and negative values in decimal attribute using DataAnnotations?

2

I have a class with decimals that can receive a value of -10.00 to 10.00 ( including 0 ), equivalent is a numeric (5.2) . The problem is that when creating my MetaData class, even specifying the range validation has not worked. Home Note: In my View it's all right, I'm using ValidationMessageFor . Home My code (Excerpt):

[Required(ErrorMessageResourceName = "VALIDACAO_REQUERIDO", ErrorMessageResourceType = typeof(Resources))]
[Range(-10.00, 10.00, ErrorMessage = "{0} deve estar entre {1} e {2}")]
public decimal Valor;
    
asked by anonymous 29.07.2015 / 15:34

1 answer

1
[Range(typeof(decimal), "-10", "10")]
    
29.07.2015 / 17:01