zod
zod copied to clipboard
Strip object values that fail member validation
The strip method allows for invalid keys to get stripped, but would love an equivalent for invalid values to help make our site more robust.
I see the suggestions in this similar issue, but the painful part with those is that every key that can possibly be invalid would need to have the transform applied; in a large schema with like 40 members, that's fairly annoying.
I guess one idea is that I can do something like (with a mapValues()
helper we have):
const stripBadValuesSchema = z.object(mapValues({
foo: z.string(),
bar: z.number()
}, schema => schema.or(z.unknown().transform(() => undefined)));
but wondering if there's a more idiomatic way to do this. Thanks!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
ding dong
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
still an issuse
Omar
On Wed, Aug 31, 2022 at 8:24 AM, stale[bot] @.***> wrote:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
— Reply to this email directly, view it on GitHub https://github.com/colinhacks/zod/issues/1090#issuecomment-1232270558, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAONU3VMLJ7SPTAGIJI3XJTV32J4HANCNFSM5T3535WA . You are receiving this because you authored the thread.Message ID: @.***>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.