How to accept 0 and negative values in decimal attribute using Dataannotations?

Asked

Viewed 552 times

2

I have a class with values decimal which may receive a value of -10.00 to 10.00 (including 0), in Sql Server the equivalent value is a Numeric(5,2). The problem is that by creating my class Metadata, even if specifying the crease validation has not been working.
Note: In my View It’s all right, I’m using the Validationmessagefor.
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;
  • No code and no more details of the problem becomes difficult to help.

  • I just made a @bigown issue, sorry...

  • 1

    @Jedaiasrodrigues Please post the excerpt from your View, the packages.config and the web.config. I made a project with default installation and worked first using your code.

1 answer

1

[Range(typeof(decimal), "-10", "10")]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.