fix(validate): reject selects whose answer options can't be resolved - #42
Merged
Merged
Conversation
validateSubset returned [] for four cases that then converted to a broken
question or failed with a misleading error (reported from formulaid, which
uses validateSubset as its only gate):
- select_one / select_multiple with no list name, or a list with no rows
on the choices sheet → LimeSurvey L/M question with 0 answers
- select_*_from_file with no file, or a file that isn't a registered
vocabulary → "Unimplemented XLSForm type", though the type is supported
validateSubset now reports each as an error. It takes an optional
{ fileChoices } so CSVs the caller will pass to convert() count as resolved;
`formtransform validate` passes the CSVs beside the form, as xlsform2lstsv
does. The converter throws for the same cases with messages naming the
question and what's missing, and for from_file it lists the registered
vocabularies.
The validation_relevance_survey fixture was one of these: `consent` put its
list in a non-standard `list_name` survey column, so its blessed snapshot had
an L question with no answers. It now uses `select_one yes_no`; the
re-blessed TSV/DDI gain its two answers.
Closes #41
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #41 (reported from formulaid, which relies on
validateSubsetas its only gate before download).typecellvalidateSubset/ convertselect_one skala, no rows forskala[]/Lwith 0 answersselect_one(no list)[]/Lwith 0 answersselect_one_from_file foo.csv(unregistered)[]/ "Unimplemented XLSForm type"select_one_from_file(no file)[]/ same throwselect_one_from_file iso_3166_1.csv[]/ 249 answersThe
select_multiplevariants behave the same way.validateSubset(survey, choices, { fileChoices }): the new optional argument makes CSVs the caller will pass toconvert()count as resolved.SubsetOptionsis exported.formtransform validatepasses the CSVs beside the form, asxlsform2lstsvalready does. Checked by hand: an unregisteredown.csvis an error until it's placed beside the workbook.Fixture fix:
validation_relevance_survey'sconsentwas one of these cases. It put its list in a non-standardlist_namesurvey column, so its blessed snapshot froze anLquestion with 0 answers. It now readsselect_one yes_no, and the re-blessed TSV/DDI gain its two answers.Tests: new
validateSubsetcases for every row in the table. The two "handles missing choice list gracefully" tests now expect the error.npm run validateis clean.note).🤖 Generated with Claude Code