Example #1
0
 /// ******************************************************************
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidatorResult">class</see>.
 /// </summary>
 /// <param name="ErrorMessage"></param>
 /// <param name="fieldName"></param>
 /// <param name="level"></param>
 /// <param name="errorCode"></param>
 public ValidatorResult(string ErrorMessage, string fieldName, ValidatorResultLevel level, int errorCode)
 {
     ValidationMessage = ErrorMessage;
     FieldName         = fieldName;
     Level             = level;
     ErrorCode         = errorCode;
 }
Example #2
0
        public void SetResult(bool Result, string ErrorMsg, int ErrorCode)
        {
            if (Result ^ NegateNextValidationResult)
            {
                ValidatorObj.AddValidationError(ErrorMsg, FieldName, NextFailureResultLevel,
                                                NextErrorCode ?? ErrorCode);
            }


            NegateNextValidationResult = false;
            NextFailureResultLevel     = ValidatorResultLevel.Error;
            NextErrorCode = null;
        }
Example #3
0
        public void AddValidationError(string Message, string FieldName, ValidatorResultLevel Level, int errorCode)
        {
            if (Mode == ErrorMode.OneErrorPerField)
            {
                foreach (var Error in ValidatorResults)
                {
                    if (Error.FieldName == FieldName)
                    {
                        return;
                    }
                }
            }


            ValidatorResults.Add(new ValidatorResult(Message, FieldName, Level, errorCode));
        }
Example #4
0
        /// ***********************************************************
        /// <summary>
        /// Add a new validation error to the list of validation errors
        /// </summary>
        /// <param name="Message"></param>
        /// <param name="FieldName"></param>
        /// <param name="Level"></param>
        /// <param name="errorCode"></param>
        public void AddValidationError(string Message, string FieldName, ValidatorResultLevel Level, int errorCode)
        {
            // Should we only allow one error per fieldname?
            if (Mode == ErrorMode.OneErrorPerField)
            {
                // Check if an error for this fieldname already exists
                foreach (var Error in ValidatorResults)
                {
                    if (Error.FieldName == FieldName)
                    {
                        return;
                    }
                }
            }

            // If we get here, add the new item.
            ValidatorResults.Add(new ValidatorResult(Message, FieldName, Level, errorCode));
        }
Example #5
0
 public TValidator WarnUnless()
 {
     NextFailureResultLevel = ValidatorResultLevel.Warning;
     return((TValidator)this);
 }