public virtual void ValidateRow(CsvRow row) { if (row.Index > this.MaximumRowCount) { throw new CsvTooManyRowsException(this.MaximumRowCount); } foreach (KeyValuePair <string, ProviderPropertyDefinition> keyValuePair in this.RequiredColumns) { string key = keyValuePair.Key; string value = row[key]; ProviderPropertyDefinition value2 = keyValuePair.Value; if (value.IsNullOrBlank()) { PropertyValidationError error = new PropertyValidationError(DataStrings.PropertyIsMandatory, value2, null); this.OnPropertyValidationError(row, key, error); } } foreach (KeyValuePair <string, string> keyValuePair2 in row.GetExistingValues()) { string key2 = keyValuePair2.Key; string value3 = keyValuePair2.Value ?? ""; ProviderPropertyDefinition propertyDefinition = this.GetPropertyDefinition(key2); if (propertyDefinition != null) { foreach (PropertyDefinitionConstraint propertyDefinitionConstraint in propertyDefinition.AllConstraints) { PropertyConstraintViolationError propertyConstraintViolationError = propertyDefinitionConstraint.Validate(value3, propertyDefinition, null); if (propertyConstraintViolationError != null) { this.OnPropertyValidationError(row, key2, propertyConstraintViolationError); } } } } }
public bool Equals(PropertyConstraintViolationError other) { return(other != null && object.Equals(this.Constraint, other.Constraint) && base.Equals(other)); }
public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag) { string text = (string)value; if (string.IsNullOrEmpty(text)) { return(null); } if (text.Length > this.maxLength) { return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationObjectIsBeyondRange(this.maxLength.ToString()), propertyDefinition, value, this)); } int num = 0; if (!int.TryParse(text, out num)) { char[] separator = new char[] { this.pairDelimiter }; char[] separator2 = new char[] { this.extensionValueDelimiter }; string[] array = text.Split(separator); string[] array2 = array; int i = 0; while (i < array2.Length) { string text2 = array2[i]; string[] array3 = text2.Split(separator2); PropertyConstraintViolationError result; if (array3.Length != 2) { result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationMalformedExtensionValuePair(text2), propertyDefinition, value, this); } else if (array3[0].Length == 0) { result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationMalformedExtensionValuePair(text2), propertyDefinition, value, this); } else { int num2 = 0; if (!int.TryParse(array3[1], out num2)) { result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationMalformedExtensionValuePair(text2), propertyDefinition, value, this); } else { if (num2 >= this.minValue && num2 <= this.maxValue) { i++; continue; } result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationValueOutOfRange(this.minValue.ToString(), this.maxValue.ToString(), num2.ToString()), propertyDefinition, value, this); } } return(result); } return(null); } if (num < this.minValue) { return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationObjectIsBelowRange(this.minValue.ToString()), propertyDefinition, value, this)); } if (num > this.maxValue) { return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationObjectIsBeyondRange(this.maxValue.ToString()), propertyDefinition, value, this)); } return(null); }