zod icon indicating copy to clipboard operation
zod copied to clipboard

Add an `unwrap` alias called `nonNullable`?

Open Tyler-Murphy opened this issue 4 years ago • 13 comments

It's great to see that unwrap now exists! Thanks for adding it,

I had trouble finding unwrap, and the name isn't intuitive to me. I worry I'll have trouble finding it again in the future, since I don't use zod very often.

What do you think of adding an alias for unwrap called nonNullable? It was the first thing that came to mind for me when I was searching for this feature since Typescript has a utility type called NonNullable.

Tyler-Murphy avatar May 28 '21 21:05 Tyler-Murphy

I second this motion

zomars avatar Jan 18 '22 02:01 zomars

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 Mar 19 '22 02:03 stale[bot]

I'm still interested in this.

Tyler-Murphy avatar Mar 19 '22 21:03 Tyler-Murphy

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 18 '22 22:05 stale[bot]

Bumping this!

zomars avatar May 18 '22 22:05 zomars

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 18 '22 01:07 stale[bot]

I'm still interested.

Tyler-Murphy avatar Jul 19 '22 19:07 Tyler-Murphy

I'm interested.

jeeasistio avatar Jul 30 '22 10:07 jeeasistio

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 28 '22 16:09 stale[bot]

For context here, we use unwrap to mean unwrapping in more contexts than just unwrapping a nullable schema, so I think it would be a misnomer for us to alias unwrap to nonNullable in general. Can probably do a better job of documenting this part of the code, but I think there is little chance of this happening at the moment.

scotttrinh avatar Sep 28 '22 17:09 scotttrinh

I see. What else is it for? I didn't find anything in a quick search.

Since it doesn't make sense as an alias, I think this request could be for a new nonNullable method, instead, that disallows null and undefined, like typescript's NonNullable

Why is there little chance? I'm happy to submit a PR if it's just an issue of getting it done.

Side note, maybe for docs: I noticed that something that's made nullish-able with .nullish() needs to be unwrap()ed twice before you get back the non-optional, non-nullable type, which was kind of confusing.

Tyler-Murphy avatar Sep 29 '22 01:09 Tyler-Murphy

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 28 '22 04:11 stale[bot]

Don't close

Tyler-Murphy avatar Nov 28 '22 20:11 Tyler-Murphy

Since it doesn't make sense as an alias, I think this request could be for a new nonNullable method, instead, that disallows null and undefined, like typescript's NonNullable

This looks like a good idea.

I'm happy to submit a PR if it's just an issue of getting it done

Feel free to submit a PR. No guarantees that it will get added, but at least it keeps things moving in the right direction.

JacobWeisenburger avatar Dec 27 '22 02:12 JacobWeisenburger