public void AddBoundary(ValidationBoundary boundary) { _ListBoundaries.Add(boundary); }
private bool ValidateRange(Property p, ReadOnlySpan <char> range) { if (p.DataTypeEnum == EnumDataType.STRING) { var a = ValidateBoundary(p, range); if (!a.Item1) { return(false); } this.AddValue(range.ToString()); } else { var pos1 = range.IndexOf('#'); if (pos1 == -1) // no range, one value { var a = ValidateBoundary(p, range); if (!a.Item1) { return(false); } this.AddValue(range.ToString()); } else { var bound = new ValidationBoundary(); if (pos1 == 0) // range with left infinite bound { var r1 = range.Slice(pos1 + 1); var b = ValidateBoundary(p, r1.Trim()); if (!b.Item1) { return(false); } bound.BoundaryMax = r1.ToString(); this.AddBoundary(bound); } else { var r1 = range.Slice(0, pos1); var pos2 = range.Slice(pos1 + 1).IndexOf('#'); if (pos2 == -1) // normal range with two boundaries { var r = r1.Trim(); var a = ValidateBoundary(p, r); if (!a.Item1) { return(false); } bound.BoundaryMin = r.ToString(); var r2 = range.Slice(pos1 + 1); r = r2.Trim(); var b = ValidateBoundary(p, r); if (!b.Item1) { return(false); } if (r.Length > 0) { bound.BoundaryMax = r.ToString(); } if (a.Item2 != null && b.Item2 != null && a.Item2.CompareTo(b.Item2) > 0) { this.AddError($"Left limit of range is greater than right limit of range \"{range.ToString()}\""); return(false); } this.AddBoundary(bound); } else // wrong range { this.AddError($"Can't parse data range \"{range.ToString()}\". Limit separator '#' used more than ones. Sample of usage: 1;3-4;6"); return(false); } } } } return(true); }