How to specify a min but no max decimal using the range data annotation attribute?

后端 未结 10 1721
旧时难觅i
旧时难觅i 2021-01-31 01:02

I would like to specify that a decimal field for a price must be >= 0 but I don\'t really want to impose a max value.

Here\'s what I have so far...I\'m not sure what the

10条回答
  •  温柔的废话
    2021-01-31 01:22

    How about something like this:

    [Range(0.0, Double.MaxValue, ErrorMessage = "The field {0} must be greater than {1}.")]
    

    That should do what you are looking for and you can avoid using strings.

提交回复
热议问题