private void ReportMissingField(SchemaEntry column) { string message = string.Format("The {0} is missing its {1}.", _dtoName, column.ColumnName); ValidationIssue.Code errorCode = GetIssueCode(column.ColumnType); ValidationIssues.Add(errorCode, message); }
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); } }
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); } }
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); } }
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); }