public string GetErrorMessage(ValidationError validationError)
        {
            string format;

            if (_formats.TryGetValue(validationError.Rule.RuleKind, out format))
            {
                return string.Format(format, validationError.ValidationArguments);
            }

            return string.Format("Rule {0} failed.", validationError.Rule);
        }
Example #2
0
        public bool HasError(CachedExpression cachedExpression, object value, out ValidationError[] validationErrors)
        {
            List<ValidationError> result;
            if (_hasExpressionError.TryGetValue(new CachedExpressionObjectPair(cachedExpression, value), out result))
            {
                validationErrors = result.ToArray();
                return true;
            }

            validationErrors = null;
            return false;
        }
Example #3
0
        public virtual void AddError(ValidationError validationError)
        {
            _hasErrors = true;
            CachedExpressionObjectPair key = new CachedExpressionObjectPair(validationError.CachedExpression, validationError.Value);
            List<ValidationError> validationErrors;

            if (_hasExpressionError.TryGetValue(key, out validationErrors))
            {
                validationErrors.Add(validationError);
            }
            else
            {
                _hasExpressionError.Add(key, new ValidationError[] { validationError }.ToList());
            }
        }