Skip to content

Conversation

juheiseflink
Copy link
Contributor

@juheiseflink juheiseflink commented Apr 15, 2025

This PR changes the JSON validator so that when yamlAsJson=true and allowMultipleDocuments=true all documents within the file are validated with the given schema.

  • yamlAsJson is true the data will always be an array; if there's only one doc in the YAML this array will be a length of 1
  • if allowMultipleDocuments is true as well then the data is parsed with parseAllDocuments, otherwise just parse (which is single doc)
  • if we have multiple docs then the index of the document is being attached to the error message to allow pointing to the correct location

I hope this PR fulfils the expectations for contributions, otherwise I'd be happy to iterate.

fixes #83

Copy link
Owner

@GrantBirki GrantBirki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🎉 Thank you so much for your contributions here ❤️

@GrantBirki GrantBirki merged commit b6415d0 into GrantBirki:main Apr 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Error: ❌ failed to parse JSON file" when running with multi-document YAML files as JSON

2 participants