colinhacks / zod

TypeScript-first schema validation with static type inference
https://zod.dev
MIT License
33.09k stars 1.15k forks source link

feat: added support for hostname method in z.string() #3589 #3692

Open Kumar06Lav opened 1 month ago

Kumar06Lav commented 1 month ago

Added support for the hostname method in z.string() for enhanced string validation. This feature introduces a dedicated method to validate domain names, including Punycode, as well as IPv4 and IPv6 addresses(in square brackets). The new validation method ensures that valid hostnames meet the appropriate criteria and excludes invalid patterns.

This implementation was done for ticket #3589.

Changes:

Implemented the hostname method to validate: Domain names, including those encoded in Punycode. IPv4 addresses. IPv6 addresses enclosed in square brackets. Updated regex patterns to accurately handle valid and invalid hostname cases. Added comprehensive test cases to ensure robustness and correctness of the new validation method. Updated documentation to include details about the hostname method and usage examples.

netlify[bot] commented 1 month ago

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
Latest commit 342fc3236c12d5fae881b8d33fc609ddcdefb72e
Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/66b4eb2929b18a0008f7986e
Deploy Preview https://deploy-preview-3692--guileless-rolypoly-866f8a.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Kumar06Lav commented 4 weeks ago

@colinhacks Could you please help me with review of my PR and merging it(if everything is fine)?