zod
zod copied to clipboard
Validate array uniqueness
From discussion: #2316
TODO
- [x] Implement array of primitives uniqueness
- [x] Implement array of complex objects uniqueness
Thanks for the help: @ramos-ph and @fwoelffel
Deploy Preview for guileless-rolypoly-866f8a ready!
| Name | Link |
|---|---|
| Latest commit | 68d83b74f0cd9e8b4dbe8b9753706bfe89af2dbc |
| Latest deploy log | https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/66283b3cf8e5c5000892af19 |
| Deploy Preview | https://deploy-preview-2672--guileless-rolypoly-866f8a.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
What suggestions do you have for array of complex objects uniqueness? I have one that would be make the objects elements from array flatten to simplifies the comparison between.
What suggestions do you have for array of complex objects uniqueness? I have one that would be make the objects elements from array flatten to simplifies the comparison between.
Class-validator seems to be doing a simple comparison
https://github.com/typestack/class-validator/blob/262a3c6369b9a9fc81846a39b62b6a2a21bd8fab/src/decorator/array/ArrayUnique.ts#L7-L20
@colinhacks could you take a look, when you have a free time?
@joaoGabriel55 As discussed here, https://github.com/colinhacks/zod/discussions/2316#discussioncomment-6979061, would it be possible to add an options which would display duplicate items?
@joaoGabriel55 As discussed here, #2316 (reply in thread), would it be possible to add an options which would display duplicate items?
yeah!
@colinhacks any thoughts about this?
Thanks! I like this a lot, especially identifier. I'm merging this into the v4 branch. Some version of this will land in Zod 4, but — as a heads up — it may be a while, and this feature/API will likely undergo some changes in the interim.