Beispiel #1
0
 private static Expression <Func <string, string, ValidateResult> > CreateValidateStringMinLengthExp(int minLength)
 {
     return((name, value) =>
            value.Length < minLength
             ? ValidateResult.Error($"{name}长度最小是{minLength}")
             : ValidateResult.Ok());
 }
Beispiel #2
0
 private static Expression <Func <string, string, ValidateResult> > CreateValidateStringRequiredExp()
 {
     return((name, value) =>
            string.IsNullOrEmpty(value)
             ? ValidateResult.Error($"{name}不能为空")
             : ValidateResult.Ok());
 }
Beispiel #3
0
 public static ValidateResult ValidateStringMinLength(string name, string value, int minLength)
 {
     return(value.Length < minLength?
            ValidateResult.Error($"{name}长度最小是{minLength}")
                :
                ValidateResult.Ok());
 }
Beispiel #4
0
 public static ValidateResult ValidateNameRequired(string name, string value)
 {
     return(string.IsNullOrEmpty(value) ?
            ValidateResult.Error($"{name}不能为空")
         :
            ValidateResult.Ok());
 }
Beispiel #5
0
 public static ValidateResult ValidateCode(string name, string value, int minLength)
 {
     if (string.IsNullOrEmpty(value))
     {
         return(ValidateResult.Error($"{name}不能为空"));
     }
     if (value.Length < minLength)
     {
         return(ValidateResult.Error($"{name}长度最小是{minLength}"));
     }
     return(ValidateResult.Ok());
 }
Beispiel #6
0
 public static ValidateResult ValidateCode(CreateClaptrapInput input, int minLength)
 {
     if (string.IsNullOrEmpty(input.Name))
     {
         return(ValidateResult.Error($"{nameof(input.Name)}不能为空"));
     }
     if (input.Name.Length < minLength)
     {
         return(ValidateResult.Error($"{nameof(input.Name)}长度最小是{minLength}"));
     }
     return(ValidateResult.Ok());
 }