Esempio n. 1
0
        public void Invoke(object value, IValidationReport report, ValidationReportDepth depth)
        {
            //If validating an Expression that has already failed a rule, then skip.
            if (depth == ValidationReportDepth.FieldShortCircuit && report.HasError(value, _originatingExpression))
            {
                return;
            }

            var originatingValue = (T)value;
            R   valueToValidate;

            if (!_valueToValidate.TryGetValue(originatingValue, out valueToValidate))
            {
                return;
            }
            var result = _rule.Validate(valueToValidate);

            if (!result.IsValid)
            {
                var culpritResults = _culpritResolver.Resolve(originatingValue);
                foreach (var culpritResult in culpritResults)
                {
                    report.AddError(new ValidationError(_rule, culpritResult.Expression, result.Arguments, culpritResult.Value, originatingValue, _originatingExpression));
                }
            }
        }
 public void Invoke(object value, IValidationReport report, ValidationReportDepth depth)
 {
     if (_condition.Invoke((T)value))
     {
         _innerTrue.Validate(value, report, depth);
     }
     else
     {
         _innerFalse.Validate(value, report, depth);
     }
 }
Esempio n. 3
0
 public void Validate(object value, IValidationReport report, ValidationReportDepth depth)
 {
     if (value == null) return;
     foreach (var invoker in _invokerRegistry.GetInvokers(value.GetType()))
     {
         invoker.Invoke(value, report, depth);
         if (report.HasErrors && depth == ValidationReportDepth.ShortCircuit)
         {
             return;
         }
     }
 }
Esempio n. 4
0
        public void Invoke(object value, IValidationReport report, ValidationReportDepth depth)
        {
            if (depth == ValidationReportDepth.FieldShortCircuit && report.HasError(value, _expression))
            {
                return;
            }

            R objToValidate = _compiledExpression.Invoke((T)value);

            if (objToValidate != null)
            {
                _rulesEngine.Validate(objToValidate, report, depth);
            }
        }
Esempio n. 5
0
 public void Validate(object value, IValidationReport report, ValidationReportDepth depth)
 {
     if (value == null)
     {
         return;
     }
     foreach (var invoker in _registry.GetInvokers(value.GetType()))
     {
         invoker.Invoke(value, report, depth);
         if (report.HasErrors && depth == ValidationReportDepth.ShortCircuit)
         {
             return;
         }
     }
 }
Esempio n. 6
0
        public void Invoke(object value, IValidationReport report, ValidationReportDepth depth)
        {
            //If validating an Expression that has already failed a rule, then skip.
            if (depth == ValidationReportDepth.FieldShortCircuit && report.HasError(_expressionToBlame, value))
            {
                return;
            }

            var result = _rule.Validate(_compiledExpression.Invoke((T)value));

            if (!result.IsValid)
            {
                report.AddError(new ValidationError(_rule, _expressionToBlame, result.Arguments, value));
            }
        }
        public void Invoke(object value, IValidationReport report, ValidationReportDepth depth)
        {
            if (depth == ValidationReportDepth.FieldShortCircuit && report.HasError(_enumerableCompositionExpression, value))
            {
                return;
            }

            IEnumerable enumerableToValidate = _compiledExpression.Invoke((T)value);

            if (enumerableToValidate != null)
            {
                foreach (object objToValidate in enumerableToValidate)
                {
                    this.rulesRulesEngine.Validate(objToValidate, report, depth);
                    if (report.HasErrors && (depth == ValidationReportDepth.ShortCircuit))
                    {
                        return;
                    }
                }
            }
        }