Skip to content

Commit

Permalink
!fixup Add support for validation of length facet
Browse files Browse the repository at this point in the history
- add support for length, also set minLength and maxLength with the value of length, when hasLength is true, and those variables are queried
- ensure length and minLength and maxLength facets are not declared together (Xerces Error, but we have asserts incase Xerces validation is turned off)
- add tests for validation=limited and validation=on
- added hexBinary tests

DAFFODIL-2842
  • Loading branch information
olabusayoT committed Mar 25, 2024
1 parent bfe4639 commit c62cbac
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,23 @@
</xs:simpleType>
</xs:element>

<xs:element name="e2_6" dfdl:lengthKind="delimited" dfdl:encoding="iso-8859-1">
<xs:simpleType>
<xs:restriction base="xs:hexBinary">
<xs:minLength value="7"/>
<xs:maxLength value="7"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

<xs:element name="e2_7" dfdl:lengthKind="delimited" dfdl:encoding="iso-8859-1">
<xs:simpleType>
<xs:restriction base="xs:hexBinary">
<xs:length value="7"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

<xs:element name="e3_2" dfdl:lengthKind="delimited">
<xs:simpleType>
<xs:restriction base="ex:stMaxLength_2">
Expand Down Expand Up @@ -660,7 +677,39 @@

</tdml:validationErrors>
</tdml:parserTestCase>


<tdml:parserTestCase name="validation_testFacets_01"
root="e2_6" model="TestFacets"
description="validates hexBinary against min/maxLength facet"
validation="limited">

<tdml:document>
<tdml:documentPart type="byte">deadbeefdafada</tdml:documentPart>
</tdml:document>

<tdml:infoset>
<tdml:dfdlInfoset>
<ex:e2_6>DEADBEEFDAFADA</ex:e2_6>
</tdml:dfdlInfoset>
</tdml:infoset>

</tdml:parserTestCase>

<tdml:parserTestCase name="validation_testFacets_02"
root="e2_7" model="TestFacets"
description="validates hexBinary against length facet"
validation="limited">

<tdml:document>
<tdml:documentPart type="byte">deadbeefdafada</tdml:documentPart>
</tdml:document>

<tdml:infoset>
<tdml:dfdlInfoset>
<ex:e2_7>DEADBEEFDAFADA</ex:e2_7>
</tdml:dfdlInfoset>
</tdml:infoset>
</tdml:parserTestCase>
<!--
Test name: checkEnumeration_Pass_limited
Schema: TestFacets
Expand Down Expand Up @@ -2032,7 +2081,7 @@
</xs:element>
</tdml:defineSchema>

<tdml:parserTestCase name="validation_testFacets_01"
<tdml:parserTestCase name="validation_testFacets2_01"
root="e2_5" model="TestFacets2"
description="checks that length cannot be used with min/maxLength"
validation="limited">
Expand All @@ -2051,7 +2100,7 @@

</tdml:parserTestCase>

<tdml:parserTestCase name="validation_testFacets_02"
<tdml:parserTestCase name="validation_testFacets2_02"
root="e2_5" model="TestFacets2"
description="checks that length cannot be used with min/maxLength"
validation="on">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ class TestValidationErr {
@Test def test_validation_testFacets_02(): Unit = {
runner.runOneTest("validation_testFacets_02")
}
@Test def test_validation_testFacets2_01(): Unit = {
runner.runOneTest("validation_testFacets2_01")
}
@Test def test_validation_testFacets2_02(): Unit = {
runner.runOneTest("validation_testFacets2_02")
}

@Test def test_floatExclusiveValid(): Unit = { runner.runOneTest("floatExclusiveValid") }
@Test def test_floatExclusiveInf(): Unit = { runner.runOneTest("floatExclusiveInf") }
Expand Down

0 comments on commit c62cbac

Please sign in to comment.