Skip to content

fix(js/core): fix ValidationResponse type and cache ajv validators#5201

Open
7hokerz wants to merge 2 commits intogenkit-ai:mainfrom
7hokerz:7hokerz/fix-validate-schema-type
Open

fix(js/core): fix ValidationResponse type and cache ajv validators#5201
7hokerz wants to merge 2 commits intogenkit-ai:mainfrom
7hokerz:7hokerz/fix-validate-schema-type

Conversation

@7hokerz
Copy link
Copy Markdown
Contributor

@7hokerz 7hokerz commented Apr 28, 2026

Description here... Help the reviewer by:

  • Fixed validateSchema function to return ValidationResponse instead of using the previously unused type.
  • Enabled caching via ajvValidators in the validation process.
  • This changes Improve type safety by repurposing the previously unused ValidationResponse as the fixed return type for validateSchema

Checklist (if applicable):

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the schema validation logic in js/core/src/schema.ts, including renaming the AJV validator cache and error mapping functions, and updating the ValidationResponse type for improved clarity. The validateSchema function was updated to better handle caching and return structures. Feedback highlights a potential TypeError when using boolean schemas as WeakMap keys, the need for safer handling of optional error messages in AJV, and the importance of maintaining safety checks when processing validation errors.

Comment thread js/core/src/schema.ts
Comment thread js/core/src/schema.ts
Comment thread js/core/src/schema.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant