gpt4 book ai didi

c# - ASP.NET MVC 2 和 ComponentModel.DataAnnotations 验证 : minimum value attribute

转载 作者:太空狗 更新时间:2023-10-29 22:20:48 33 4
gpt4 key购买 nike

我在我的 ASP.NET MVC 2 站点中用 System.ComponentModel.DataAnnotations 验证属性装饰了一个 ViewModel。对于我的一个名为 Price 的字段,我想验证该值不低于某个范围,在本例中为 0。

我知道 RangeAttribute 存在用于较低和较高范围的验证,但是确实存在类似 MinimumValueAttribute 的东西用于仅较低范围的验证?

如果没有,我想我会自己动手。

最佳答案

在你自己滚动之前 - 试试 [Range(0.05, Double.MaxValue)]

关于c# - ASP.NET MVC 2 和 ComponentModel.DataAnnotations 验证 : minimum value attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3176459/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com