Altinn / Altinn/app-frontend-react

Restrictions on `xsd:gYear` does not work

Open
#856 1 comment 0 reactions 0 assignees View on GitHub
kind/bug
Dominant language
TypeScript
Stars
21
Forks
33
Avg merge
6d 23h
Merged PRs (30d)
3

Description

### 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 `



 

```

This causes the following json schema to be generated.

```json
"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](https://user-images.githubusercontent.com/131616/214574888-0a08ab20-f94e-4a21-8897-a64a6c03fe4b.jpg)

### 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

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with the schema from the issue, using the previous app commit linked in Additional Information, then inspect how the frontend handles formatMinimum and formatExclusiveMaximum for the year format. Compare the behavior with commit 23c3bc5, and verify that xsd:gYear restrictions no longer crash the app and are handled as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.