コード例 #1
0
 public static PropertyValidator <TProperty> ValidIfTrue <TProperty>(
     this PropertyValidator <TProperty> validator,
     Func <TProperty, bool> predicate,
     string errorMessage)
 {
     return(new PropertyValidator <TProperty>(validator, value => predicate(value)
         ? PropertyValidationResult.Success
         : new PropertyValidationResult(ValidationStatus.Invalid, errorMessage)));
 }
コード例 #2
0
 public static PropertyValidator <string> Required(this PropertyValidator <string> validator, string errorMessage)
 {
     return(validator.ValidIfTrue(value => !string.IsNullOrEmpty(value), errorMessage));
 }