Altinn / app-frontend-react

Altinn application React frontend
BSD 3-Clause "New" or "Revised" License
18 stars 31 forks source link

Restrictions on `xsd:gYear` does not work #856

Open ivarne opened 1 year ago

ivarne commented 1 year ago

Description of the bug

Not sure if this is a studio or frontend problem, but we have an app with minInclusive and maxExclusive restrictions on a <xsd:gYear element

<xsd:simpleType name="RegnskapAr-17102_Ar1980AretsAr-107" seres:elementtype="Tallrestriksjon" seres:guid="http://seres.no/guid/Finanstilsynet/Tallrestriksjon/Ar1980AretsAr-107/522188">
    <xsd:restriction base="xsd:gYear">
        <xsd:minInclusive value="1980"/>
        <xsd:maxExclusive value="9999"/>
    </xsd:restriction>
</xsd:simpleType>

This causes the following json schema to be generated.

    "RegnskapAr-17102_Ar1980AretsAr-107": {
      "@xsdType": "gYear",
      "type": "string",
      "format": "year",
      "@xsdStructure": "XmlSchemaSimpleTypeRestriction",
      "formatMinimum": "1980",
      "formatExclusiveMaximum": "9999",
      "@xsdUnhandledAttributes": {
        "seres:elementtype": "Tallrestriksjon",
        "seres:guid": "http://seres.no/guid/Finanstilsynet/Tallrestriksjon/Ar1980AretsAr-107/522188"
      }
    },

This causes the app to crash with the following error in the console Error: "formatMinimum": format "year" does not define "compare" function 2fc0220d-37ea-4848-8510-ead6d0c199c4

Additional Information

See commit that "fixed" this issue by removing restrictions https://altinn.studio/repos/krt/krt-1007a-1/commit/23c3bc5cf3ab63c229136bf1c0d504df82d5bd40

The previous commit can be used to test the issue. https://altinn.studio/repos/krt/krt-1007a-1/src/commit/6305ec84365740f627705a6a24282d1f1aa26f6f

ivarne commented 1 year ago

Add that this is low priority for us now, but when I figured it out I wanted to document it somewhere. The workaround by removing the restrictions works fine.