Skip to content

Fix v4 http_url schema - #26

Merged
satvik007 merged 1 commit into
mainfrom
dev/himanshu/support-to-ignore-fields
Aug 5, 2026
Merged

Fix v4 http_url schema#26
satvik007 merged 1 commit into
mainfrom
dev/himanshu/support-to-ignore-fields

Conversation

@hi-rai

@hi-rai hi-rai commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

In Zod v4 mode, renderV4FormatCheck mapped validate:"http_url" to .check(z.httpUrl()).

z.httpUrl() is shorthand for z.url({ protocol: /^https?$/, hostname: z.regexes.domain }), and the hostname regex only accepts dotted, TLD-style domains. But go-playground/validator's http_url rule is url.Parse-based: it only requires an http/https scheme and a non-empty host. The generated Zod schema therefore rejects values the Go validator accepts:

Value Go http_url z.httpUrl()
https://localhost:8080/path valid rejected
http://127.0.0.1:9000/x valid rejected
https://intranet-host/browse/X valid rejected
https://example.com/a?b=c valid valid

The updated .check(z.url({ protocol: /^https?$/ })) now matches go-playground/validator's behavior

@hi-rai
hi-rai requested a review from satvik007 August 4, 2026 05:27
@hi-rai hi-rai self-assigned this Aug 4, 2026
@github-actions github-actions Bot deleted a comment from claude Bot Aug 4, 2026
@satvik007
satvik007 merged commit 1d6a196 into main Aug 5, 2026
2 checks passed
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