Altinn / app-frontend-react

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

Frontend throws error when using a XSD uploaded with `xsd:gYear` type #2023

Open kentare opened 1 month ago

kentare commented 1 month ago

Description of the bug

Frontend throws error when using a XSD uploaded with xsd:gYear type

Uploaded XSD:

<xsd:simpleType seres:elementtype="Tallrestriksjon" name="RegnskapAr-17102_Verdirestriksjon">
  <xsd:restriction base="xsd:gYear">
    <xsd:minInclusive value="1980"/>
    <xsd:maxInclusive value="9999"/>
  </xsd:restriction>
</xsd:simpleType>

The error:

Error: "formatMaximum": format "year" does not define "compare" function

Schema generated:

    "RegnskapAr-17102_Verdirestriksjon": {
      "@xsdType": "gYear",
      "type": "string",
      "format": "year",
      "@xsdStructure": "XmlSchemaSimpleTypeRestriction",
      "formatMinimum": "1980",
      "formatMaximum": "9999",
      "@xsdUnhandledAttributes": {
        "seres:elementtype": "Tallrestriksjon"
      }
    }

Steps To Reproduce

  1. Upload a XSD with "gYear" as specified in the description and generate models
  2. The app should crash when loading

Additional Information

The XSD is a part of imgrate migrating 2 to 3.

Slack discussion with example XSD: https://altinn.slack.com/archives/C02EJ9HKQA3/p1713166049825899