Exemple #1
0
        public override Task <IValidateResult> ValidateAsync(IValidateResult result, TProperty value, string name, string error)
        {
            var res = m_Func(value);

            if (res != null)
            {
                result.Merge(res);
            }
            return(Task.FromResult(result));
        }
 private async void ValidateNextRule(ValidateContext context, IValidateResult result, int index, IValidateRule rule)
 {
     var nextResult = await rule.ValidateAsync(context);
     if (!nextResult.IsValid)
     {
         foreach (var failure in nextResult.Failures)
         {
             failure.Name = string.Format(string.IsNullOrEmpty(failure.Name) ? "{0}[{1}]{2}" : "{0}[{1}].{2}", ValueName, index, failure.Name);
         }
     }
     result.Merge(nextResult.Failures);
 }
Exemple #3
0
        private async void ValidateNextRule(ValidateContext context, IValidateResult result, int index, IValidateRule rule)
        {
            var nextResult = await rule.ValidateAsync(context);

            if (!nextResult.IsValid)
            {
                foreach (var failure in nextResult.Failures)
                {
                    failure.Name = string.Format(string.IsNullOrEmpty(failure.Name) ? "{0}[{1}]{2}" : "{0}[{1}].{2}", ValueName, index, failure.Name);
                }
            }
            result.Merge(nextResult.Failures);
        }
 private async void ValidateNextRuleList(ValidateContext context, IValidateResult result)
 {
     foreach (var nextRule in NextRuleList)
     {
         if (result.IsValid || context.Option == ValidateOption.Continue)
         {
             var nextResult = await nextRule.ValidateAsync(context);
             result.Merge(nextResult.Failures);
         }
         else
             break;
     }
 }
Exemple #5
0
        private async void ValidateNextRuleList(ValidateContext context, IValidateResult result)
        {
            foreach (var nextRule in NextRuleList)
            {
                if (result.IsValid || context.Option == ValidateOption.Continue)
                {
                    var nextResult = await nextRule.ValidateAsync(context);

                    result.Merge(nextResult.Failures);
                }
                else
                {
                    break;
                }
            }
        }