Skip to content

Commit

Permalink
Merge branch 'develop' into feature/pr-template
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasdejong authored Aug 20, 2024
2 parents e57948c + 790ded8 commit 4e92e57
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Firely.Fhir.Validation/Impl/MinMaxValueValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Hl7.Fhir.ElementModel.Types;
using Hl7.Fhir.Support;
using Hl7.Fhir.Utility;
using Hl7.FhirPath.Functions;
using Newtonsoft.Json.Linq;
using System;
using System.ComponentModel;
Expand Down Expand Up @@ -105,7 +106,15 @@ ResultReport IValidatable.Validate(IScopedNode input, ValidationSettings _, Vali

try
{
if ((instanceValue is ICqlOrderable ce ? ce.CompareTo(_minMaxAnyValue) : -1) == _comparisonOutcome)
var (lt, gt) = (EqualityOperators.Compare(instanceValue, _minMaxAnyValue, "<"), EqualityOperators.Compare(instanceValue, _minMaxAnyValue, ">"));
var intResult = (lt, gt) switch
{
(true, _) => -1,
(false, true) => 1,
_ => 0
};

if (intResult == _comparisonOutcome)
{
return new IssueAssertion(_comparisonIssue, $"Value '{input.Value}' is {_comparisonLabel} {Limit.Value})")
.AsResult(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

using FluentAssertions;
using Hl7.Fhir.ElementModel;
using Hl7.Fhir.ElementModel.Types;
using Hl7.Fhir.Model;
using Hl7.Fhir.Support;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using Date = Hl7.Fhir.Model.Date;
using Integer = Hl7.Fhir.Model.Integer;

namespace Firely.Fhir.Validation.Tests
{
Expand Down Expand Up @@ -86,6 +89,12 @@ internal class MinValueValidatorData : BasicValidatorDataAttribute
PrimitiveTypeExtensions.ToTypedElement<Date, string>("1906"),
false, Issue.CONTENT_ELEMENT_PRIMITIVE_VALUE_TOO_LARGE, "PartialGreaterThan"
};
yield return new object?[]
{
_validatableMinValue,
PrimitiveTypeExtensions.ToTypedElement<Integer64, long?>(4),
true, null, "Equals"
};
}
}

Expand Down

0 comments on commit 4e92e57

Please sign in to comment.