private static ValidationCheckResult CheckRangeFromOrTo(ValidationCheckParameters <FD, FA, FV, T, D> parameters, FieldConfigurationType configurationType, bool invertProperties) { var rangeRules = parameters.GetConfigurations(configurationType); if (!rangeRules.Any()) { return(new ValidationCheckResult()); } var fieldSourceNames = rangeRules.Where(r => !r.ValueString.IsNullOrEmpty()).Select(r => r.ValueString.Trim()).ToList(); var results = new List <ValidationCheckResultEntry>(); foreach (var fieldSourceName in fieldSourceNames) { var baseFieldSource = fieldSourceName.GetFieldSource(parameters); if (baseFieldSource == null) { results.Add(GetErrorResult(ValidationErrorType.PropertyNotFoundFrom, fieldSourceName, parameters.Field.Id)); continue; } //Check whether the data types match if (parameters.Field.Type != baseFieldSource.Type) { results.Add(GetErrorResult(ValidationErrorType.DataTypesNotEqual, baseFieldSource.Id, parameters.Field.Id)); continue; } parameters.AllowNull = parameters.GetConfigurations(FieldConfigurationType.AllowNull).Any(); if (invertProperties) { var result = BaseRangeValidation <FD, FA, FV, T, D> .CheckRangeValue(parameters, parameters.Field, baseFieldSource); if (!result.IsValid) { results.AddRange(result.ValidationErrors); } } else { var result = BaseRangeValidation <FD, FA, FV, T, D> .CheckRangeValue(parameters, baseFieldSource, parameters.Field); if (!result.IsValid) { results.AddRange(result.ValidationErrors); } } } if (results.Count == 0) { return(new ValidationCheckResult()); } return(new ValidationCheckResult { ValidationErrors = results }); }
public IEnumerable <IFieldConfiguration <T> > GetConfigurations(FieldConfigurationType type) { return(FieldDefinition.Configurations.Where(c => c.ConfigurationType == type)); }