Leo*_*uda 4 nhibernate fluent-nhibernate fluentvalidation
我想使用流利的验证器验证bool属性.我应该使用哪种方法?
.NotNull()和.NotEmpty()函数不起作用.
谢谢.
小智 5
为了使用流畅的验证器验证布尔值:
创建以下规则
RuleFor(x => x.BooleanProperty)
.Must(ValidateBoolean)
.WithErrorCode("Boolean Validation Failed");
Run Code Online (Sandbox Code Playgroud)
定义谓词验证器
private bool ValidateBoolean(T arg1, bool arg2, PropertyValidatorContext arg3)
{
// validate arg2, return true if validation successful or false if failed
throw new System.NotImplementedException();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4107 次 |
| 最近记录: |