Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tests): enhance schema validation error messages with filename context #190

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ushkinaz
Copy link

Adds a helper to the output message to assist in locating "invalid" JSON in in all.json.

Example output:

Error: [File: data/json/items/ammo/shot.json#L94-L109]
 must have required property 'id', but was {
  abstract: 'shotshell_abstract',
  type: 'AMMO',
  name: { str: 'base shotshell', '//~': 'NO_I18N' },
  weight: '47 g',
  volume: '377 ml',
  longest_side: '57 mm',
  flags: [ 'IRREPLACEABLE_CONSUMABLE' ],
  material: [ 'brass', 'plastic', 'lead', 'powder' ],
  symbol: '=',
  color: 'red',
  count: 20,
  stack_size: 20,
  ammo_type: 'shot',
  casing: 'shot_hull',
  __filename: 'data/json/items/ammo/shot.json#L94-L109'
}

@ushkinaz
Copy link
Author

It was originally created for my Bright Nights fork, which requires extensive schema changes. Quickly locating problematic entries in all.json is crucial.

Also, a huge thanks for using clear, atomic commits with descriptive messages -- it made backporting ~200 commits so much easier

@ushkinaz
Copy link
Author

Arg, I messed up with formatting and cherry-picking, will update soon

@ushkinaz ushkinaz force-pushed the filename-in-schematest branch from 94da1f9 to a0dacd5 Compare February 27, 2025 15:14
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.

1 participant