Gentle.NET中提供了一个公共的数据验证框架(1.2.1或更高版本中),是基于特性描述的。

        框架里面提供了三个验证器:
        RegexValidator:使用正则表达式对字符串进行验证
  RequiredValidator:标明某字段不能为空,适合于所有类型
        RangerValidator:用于验证数字类型是否在某个范围之内

  如果愿意,也可以通过继承ValidatorBaseAttribute 来实现自己的验证器。

附表:        
 
Validator Type Purpose Example
RegexValidator String Provides generic string matching validations First letter capatilized: [RegexValidator(Expression=@"[A-Z]+[a-z])]
RequiredValidator object Provides validation for fields that should not be null or empty [RequiredValidator()]
RangeValidator Number Validates that a number is between a range. If lower or upper bounds are not specified then the appropriate Max/ Min value for that type is used [RangeValidator( Min=20.5, Max=100.5 )]

PS:文档是这样写的,但这玩意在哪儿,我居然没找到

相关文章:

  • 2021-04-02
  • 2021-12-25
  • 2021-11-30
  • 2021-07-20
  • 2021-11-11
  • 2022-01-18
  • 2021-07-14
  • 2021-07-01
猜你喜欢
  • 2021-05-24
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-09-06
相关资源
相似解决方案