Beispiel #1
0
 private void ValidateStringField(string fieldValue, SchemaEntry column)
 {
     if (!string.IsNullOrWhiteSpace(fieldValue))
     {
         if (fieldValue.Length > column.ColumnLength)
         {
             string message = string.Format("The {0} {1} is {2} long which is longer than {3} characters.", _dtoName, column.ColumnName, fieldValue.Length, column.ColumnLength);
             ValidationIssues.Add(ValidationIssue.Code.StringTooLongCode, message);
         }
     }
     else if (column.ColumnNullable == NullableType.IsNotNullable)
     {
         ReportMissingField(column);
     }
 }
Beispiel #2
0
        public void IsInRange(object value, string dtoName, ValidationIssues issues)
        {
            if (!HasRange)
            {
                return;
            }
            RangeResult result = Range.IsInRange(value);

            if (result != RangeResult.ValueInRange)
            {
                string insert = (result == RangeResult.ValueBelowMinimum)
                    ? "below the minimum allowed value"
                    : "above the maximum allowed value";
                string message = string.Format("The {0} has {1} which is {2}.", dtoName, ColumnName, insert);
                issues.Add(ValidationIssue.Code.ValueOutOfRange, message);
            }
        }
Beispiel #3
0
        public void ValidateMinimumOptionalFields(string dtoName, IEnumerable <bool> optionalFieldsPresent, int minimumCount)
        {
            int actualCount = 0;

            foreach (bool isPresent in optionalFieldsPresent)
            {
                if (isPresent)
                {
                    actualCount++;
                    if (actualCount >= minimumCount)
                    {
                        return; //we're done, just stop
                    }
                }
            }
            if (actualCount < minimumCount)
            {
                string message = string.Format("The {0} is missing at least one optional value field.", dtoName);
                ValidationIssues.Add(ValidationIssue.Code.MissingRequiredFieldCode, message);
            }
        }
Beispiel #4
0
        private void ReportParseFailure(SchemaEntry column)
        {
            string message = string.Format("The {0} {1} contains an invalid format for a {2}.", _dtoName, column.ColumnName, column.ValueType);

            ValidationIssues.Add(ValidationIssue.Code.ValueInvalidFormat, message);
        }