protected virtual void ValidateFieldValues() { var context = new RowValidationContext(this.Connection, this.Row); foreach (var field in Row.GetFields()) { if (!Row.IsAssigned(field)) { continue; } if (field.CustomAttributes == null) { continue; } var validators = field.CustomAttributes.OfType <ICustomValidator>(); foreach (var validator in validators) { context.Value = field.AsObject(this.Row); var error = CustomValidate(context, field, validator); if (error != null) { throw new ValidationError("CustomValidationError", field.PropertyName ?? field.Name, error); } } } }
protected virtual string CustomValidate(RowValidationContext context, Field field, ICustomValidator validator) { return(validator.Validate(context)); }