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

后端 未结 10 1717
旧时难觅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条回答
  •  -上瘾入骨i
    2021-01-31 01:32

    If you are concerned about the string looking nice you could do this:

        [Range(0, Double.PositiveInfinity)]
    

    This will have a default error message of:

    The field SuchAndSuch must be between 0 and Infinity.

提交回复
热议问题