pydantic-extra-types icon indicating copy to clipboard operation
pydantic-extra-types copied to clipboard

Adding basic string types - NonEmptyString, Character

Open yuti01 opened this issue 1 year ago • 3 comments

I have found myself declaring simple string types a lot and thought it would be nice to have them here. I suggest adding the following types:

  • NonEmptyString to indicate some string cannot be empty
  • Character type to indicate a string has length of exactly 1.

What do you think? Is it too pedantic? Would you use these types?

yuti01 avatar Oct 18 '24 15:10 yuti01

Sounds great! I often define these types myself, it would be really useful.

RonMoshe avatar Oct 18 '24 19:10 RonMoshe

These must be very common then I thought I was the only one using these until I've seen your issue!

Ilai-Dabush avatar Oct 18 '24 20:10 Ilai-Dabush

tbh I think these types would even fit the main pydantic lib. The char type is classic and is a built-in in C & Java. The non empty string is also a great idea and would be super useful

almogtavor avatar Oct 18 '24 23:10 almogtavor