Example #1
0
        public new string ToString()
        {
            StringBuilder msg = new StringBuilder(Tag == null ? Message : String.Format("[{0}]: {1}", Tag, Message));

            if (_nestedValidationResults != null)
            {
                msg.AppendFormat("{0}{1}", Environment.NewLine,
                                 _nestedValidationResults.ToString().Indent(1));
            }
            return(msg.ToString());
        }
Example #2
0
        public override void Validate(MemberInfo memberInfo, object value)
        {
            ChoValidationResults validationResults = new ChoValidationResults();

            foreach (IChoSurrogateValidator validator in Validators)
            {
                try
                {
                    validator.Validate(memberInfo, value);
                    return;
                }
                catch (ChoFatalApplicationException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    validationResults.AddResult(new ChoValidationResult(ex.Message));
                }
            }

            if (validationResults.Count > 0)
            {
                if (validationResults.Count == 1)
                {
                    throw new ChoValidationException("Failed to validate {0} member. {1}".FormatString(memberInfo.Name, validationResults.ToString()), validationResults);
                }
                else
                {
                    throw new ChoValidationException("Failed to validate {0} member. Must meet one of the following conditions. {2}{1}".FormatString(memberInfo.Name,
                                                                                                                                                     validationResults.ToString().Indent(), Environment.NewLine), validationResults);
                }
            }
        }
Example #3
0
        public override string ToString()
        {
            ChoValidationResults results = ChoValidation.Validate(this);

            if (results.Count == 0)
            {
                return(String.Format("SUCCESS - ShortName: {0}, Type: {1}, Override: {3} [TypeFound: {2}]", TypeShortName, TypeName, Type != null, Override));
            }
            else
            {
                return(String.Format("ERROR - ShortName: {0}, Type: {1}, Override: {3} [TypeFound: {2}], {4}[{4}{5}]",
                                     TypeShortName, TypeName, Type != null, Override, Environment.NewLine, results.ToString().Indent()));
            }
        }