-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add parseUrlSearchParams #1
Draft
razor-x
wants to merge
14
commits into
main
Choose a base branch
from
dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+447
−44
Conversation
This file contains 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
Member
razor-x
commented
Feb 25, 2025
- Add @seamapi/url-search-params-serializer for testing
- Add zod for testing
- Add parseUrlSearchParams with failing tests
@phpnode I have a minimal implementation of the parsing strategy that handles basic schemas. Let me know what you think 😄 |
razor-x
commented
Mar 4, 2025
Comment on lines
+10
to
+37
### Allowed Zod Schemas | ||
|
||
- The top-level schema must be an `z.object()` or `z.union()` of `z.object()`. | ||
- Properties may be a `z.object()` or `z.union()` of objects. | ||
- All union object types must flatten to a parseable object schema with non-conflicting property types. | ||
- Primitive properties must be a `z.string()`, `z.number()`, `z.boolean()` or `z.date()`. | ||
- Properties must be a single-value type | ||
- The primitives `z.bigint()` and `z.symbol()` are not supported. | ||
- Strings with zero length are not allowed. | ||
If not specified, a `z.string()` is always assumed to be `z.string().min(1)`. | ||
- Using `z.enum()` is allowed and equivalent to `z.string()`. | ||
- Any property may be `z.optional()` or `z.never()`. | ||
- No property may `z.void()`, `z.undefined()`, `z.any()`, or `z.unknown()`. | ||
- Any property may be `z.nullable()` except `z.array()`. | ||
- Properties that are `z.literal()` are allowed and must still obey all of these rules. | ||
- A `z.array()` must be of a single value-type. | ||
- The value-types must obey all the same basic rules | ||
for primitive object, union, and property types. | ||
- Value-types may not be `z.nullable()` or `z.undefined()`. | ||
- The value-type cannot be an `z.array()` or contain a nested `z.array()` at any level. | ||
- A `z.record()` has less-strict schema constraints but weaker parsing guarantees: | ||
- They keys must be `z.string()`. | ||
- The value-type may be a single primitive type. | ||
- The value-type may be a union of primitives. | ||
This union must include `z.string()` | ||
and all values will be parsed as `z.string()`. | ||
- The value-type may be `z.nullable()`. | ||
- The value-type may not be a `z.record()`, `z.array()`, or `z.object()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phpnode Let me know if these rules make sense 🙏🏻
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.