Skip to content

JSON Schema Validation#75

Merged
sachin-panayil merged 8 commits intov1.2.0from
sachin/jsonValidationImplementation
Oct 10, 2025
Merged

JSON Schema Validation#75
sachin-panayil merged 8 commits intov1.2.0from
sachin/jsonValidationImplementation

Conversation

@sachin-panayil
Copy link
Copy Markdown
Collaborator

@sachin-panayil sachin-panayil commented Oct 2, 2025

Add Validation for code.json

Summary

This PR implements automatic validation for code.json files using Zod, ensuring that both auto-generated and manually edited code.json files are valid before being merged.

What Changed

New Features:

  • Automatic validation before creating PRs or pushing to main
  • Automatic validation when users edit code.json in PRs
  • Type-safe validation that matches our TypeScript interface / code.json schema

How It Works

Generation Mode

  1. Action generates code.json with calculated metadata
  2. Validates the generated JSON within the code
  3. If valid: Creates PR or pushes directly
  4. If invalid: Fails with error messages

Validation Mode

  1. User edits code.json in a PR
  2. User commits changes
  3. pull request event triggers
  4. Action validates the edited JSON as a PR check
  5. If valid: Passes check and can safely merge
  6. If invalid: Fails check with error details

Testing

  1. Manually run the updateCodeJSON action
  2. Check the action logs to see if initial code validation passes
  3. Go to the newly created PR
  4. Check to see if initial PR check is running and passing
  5. Make an edit to the code.json from the browser
  6. Check to see if the PR fails or passes based on what you want to test

@sachin-panayil sachin-panayil self-assigned this Oct 2, 2025
Copy link
Copy Markdown
Contributor

@natalialuzuriaga natalialuzuriaga left a comment

Choose a reason for hiding this comment

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

Overall very solid work here especially with the docs 👏 👏 -- this is soooo important since validation will ensure data quality for our code.json files

Comment thread README.md
Comment thread src/validation.ts Outdated
Comment thread src/validation.ts Outdated
Comment thread src/validation.ts
Comment thread src/validation.ts
systems: z.array(z.string()),
subsetInHealthcare: z.array(z.string()),
userType: z.array(z.string()),
maturityModelTier: z.number(),
Copy link
Copy Markdown
Contributor

@natalialuzuriaga natalialuzuriaga Oct 7, 2025

Choose a reason for hiding this comment

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

Question: Does using the .min() function ensure that the field is filled out (aka it is a required field)? I am trying to see when it should be used and for what fields

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

whatever doesnt have the .optional() method attached to it is an optional field and can be nil but everything else is required can cannot be nil. the .min() method is there to make sure that the field is not empty @natalialuzuriaga

@sachin-panayil
Copy link
Copy Markdown
Collaborator Author

quick aside but this is working great. in the implemented requested changes commit, i changed the metaDataLastUpdated to lowercase as you requested in every place except the actual code.json file. the action reran and noticed that metaDataLastUpdated (uppercase) wasnt updated properly and expected metadataLastUpdated (lowercase) so the check failed and indicated what was going wrong. great sign! @natalialuzuriaga

Copy link
Copy Markdown
Contributor

@natalialuzuriaga natalialuzuriaga left a comment

Choose a reason for hiding this comment

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

All LGTM! Amazing job 🙌

@natalialuzuriaga
Copy link
Copy Markdown
Contributor

natalialuzuriaga commented Oct 9, 2025

quick aside but this is working great. in the implemented requested changes commit, i changed the metaDataLastUpdated to lowercase as you requested in every place except the actual code.json file. the action reran and noticed that metaDataLastUpdated (uppercase) wasnt updated properly and expected metadataLastUpdated (lowercase) so the check failed and indicated what was going wrong. great sign! @natalialuzuriaga

Yasss!!! Working as intended 🙌

@sachin-panayil sachin-panayil merged commit c939de0 into v1.2.0 Oct 10, 2025
1 check passed
@sachin-panayil sachin-panayil deleted the sachin/jsonValidationImplementation branch October 10, 2025 17:34
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.

2 participants