zod icon indicating copy to clipboard operation
zod copied to clipboard

Feature Request: async preprocess

Open FlorianWendelborn opened this issue 3 years ago • 15 comments

I’m trying to parse some minecraft NBT data with zod. However, in order to do this, one key of the object (item_bytes) first needs to be converted from the binary NBT format to a JSON-like structure.

The best way to implement this in my opinion would be to use zod’s z.preprocess(). Unfortunately, the library I’m using prismarine-nbt only exposes parse as an async function.

As far as I can tell, async preprocessing is not supported right now. I think it would be great if it’s allowed as it would really simplify parsing with async libraries.

I’d suggest either z.preprocess(async () => { /* ... */ }, z.any()) or z.preprocessAsync(async () => { /* ... */ }, z.any()) as I think either would be reasonable from an API standpoint.

FlorianWendelborn avatar Mar 12 '22 01:03 FlorianWendelborn

Yep, seems like an oversight, should be a quick addition. I'll look into it.

colinhacks avatar Mar 21 '22 18:03 colinhacks

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.

stale[bot] avatar May 20 '22 19:05 stale[bot]

@stale this issue is still relevant

FlorianWendelborn avatar May 21 '22 00:05 FlorianWendelborn

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.

stale[bot] avatar Jul 20 '22 03:07 stale[bot]

@stale don’t

FlorianWendelborn avatar Jul 20 '22 08:07 FlorianWendelborn

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.

stale[bot] avatar Sep 18 '22 10:09 stale[bot]

@stale don't

FlorianWendelborn avatar Sep 18 '22 10:09 FlorianWendelborn

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.

stale[bot] avatar Nov 17 '22 11:11 stale[bot]

@stale don't

FlorianWendelborn avatar Nov 18 '22 04:11 FlorianWendelborn

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.

stale[bot] avatar Feb 16 '23 22:02 stale[bot]

@stale don’t

FlorianWendelborn avatar Feb 23 '23 05:02 FlorianWendelborn

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.

stale[bot] avatar May 24 '23 12:05 stale[bot]

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.

stale[bot] avatar Aug 22 '23 14:08 stale[bot]