Open
Conversation
…ields to allow both PassFieldContentWithRow and PassFieldContent
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the schema validation library from Joi to Zod 4, aiming to enable automatic type inference and reduce manual TypeScript declarations. The migration significantly reduces package size from 436 kB to 128.6 kB.
Key changes:
- Replaced all Joi schemas with Zod equivalents across the codebase
- Enabled strict mode in TypeScript configuration
- Updated type definitions to use
z.infer<>for automatic type inference - Modified validation helper functions to work with Zod's API
Reviewed Changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 25 comments.
Show a summary per file
| File | Description |
|---|---|
| src/schemas/index.ts | Core schema definitions migrated from Joi to Zod, including PassProps, OverridablePassProps, and related schemas |
| src/schemas/Semantics.ts | Semantic tags schema converted to Zod with all field definitions |
| src/schemas/PassFields.ts | Pass fields schema migrated with TransitType and field structure definitions |
| src/schemas/PassFieldContent.ts | Field content validation migrated to Zod with data detector and alignment types |
| src/schemas/UpcomingPassInformation.ts | iOS 26+ upcoming pass information schema converted to Zod |
| src/schemas/SemanticTagType.ts | Semantic tag type definitions migrated (CurrencyAmount, Location, etc.) |
| src/schemas/Personalize.ts | Personalization schema converted to Zod |
| src/schemas/NFC.ts | NFC schema migrated with message length validation |
| src/schemas/Location.ts | Location schema simplified with Zod |
| src/schemas/Beacon.ts | Beacon schema converted with UUID and number range validation |
| src/schemas/Barcode.ts | Barcode format and message validation migrated |
| src/schemas/Certificates.ts | Certificate schema updated to use Zod's instanceof check |
| src/PKPass.ts | Updated to use Zod validation methods and adjusted type assertions |
| src/FieldsArray.ts | Modified to work with Zod schemas and improved type safety |
| src/utils.ts | Return type of processDate changed from string | undefined to string |
| tsconfig.json | Added strict mode |
| package.json | Added zod@4.1.12 dependency (Joi remains, should likely be removed) |
Critical Issues Found: The migration contains numerous incorrect Zod API usages including:
z.iso.datetime()(non-existent method)z.literal()with arrays instead ofz.enum().check()method (doesn't exist in Zod)z.url({ protocol: /.../ })with invalid syntaxz.json(),z.email(),z.maxLength()used as standalone schemas
These issues will cause runtime failures and the code will not function correctly with the current implementation.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ntics structure to not have to put optional to all the properties
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.
Description
This PR handles the migration from Joi, from which this repository is stuck due to an issue with Typescript, to Zod 4 - which I was waiting due to a missing thing in the previous versions.
This helps by removing manual Typescript declarations, which led to #256, for automatic inference.
I'm not sure this is a breaking change yet. The project exports types of schemas, so it will likely be a breaking, even if they shouldn't be a problem.
The only relevant statistic I can see is that the package tar.gz, sadly, passes from 436 kB to 1.5 Mb (but probably there are just a lot more of comments and repeated definitions, due to Zod).
After the last few checks and review from Copilot, I'll leave this here for a while, just to give it time to receive some feedbacks.
Check relevant checkboxes
npm test) and they passedRelevant information