Invalid examples in new fixtures files
See original GitHub issueI am currently going through implementing the new fixtures released as part of 3.9.0 and have encountered an issue with some of the new hidden examples. Take the following from date input:
- name: with values
hidden: true
data:
items:
-
id: day
-
id: month
-
id: year
value: 2018
This example is missing name
and label
keys from each item which are marked as required: true
in the specification of the component. This is just one instance of this kind of issue, I have encountered several others (Happy to compile a list of all the issues once we’ve bottomed out the discussion…)
I think I would expect all the examples in these files to be valid relative to the specification. It’s causing me a slight issue in govuk-react-jsx whereby my components do not expect these values to be un-set. I had started to embark on making the components more resilient, but thought I would open this ticket before I go too far. I could make my components handle these invalid examples by guarding against these kinds of things, but is that the right thing to do? If people were omitting these attributes whilst actually using my library in the wild, it would be outputting incorrect markup - I actually want my library to throw errors when people do this, not silently swallow them.
Which leads me to think I don’t want to guard against this, and that the base examples should be valid relative to the spec.
What do you think? Perhaps the build tool could even be validating examples against the spec to ensure these don’t get through.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
Hi @vanitabarrett - I’ve noticed a similar / related issue in that some of the fixtures contain lots of references to
undefined
. For example in the textarea examples you see things like:I think that this is essentially the same issue and would be fixed once all examples contain the required attributes, but I just wanted to flag it for awareness. Don’t know whether you want to track this in a separate ticket
Thanks @vanitabarrett. My plan is to try and handle the irregularities but leave comments so I can remove the workarounds again in future, so I’m not blocked. I’ll post a summary of my thoughts once I’ve worked through it all so you can judge whether to take action or not in each case.