question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deprecate string.nonempty?

See original GitHub issue

It can be confusing using it with .min when they can both serve the same purpose. For example, it’s impossible to know what happens if I do the following without consulting the source code:

z.string().min(2).nonempty();

Does that remove my minimum length of 2 on .min? The answer is yes, but it’s unclear. I think it would be better to make users just use .min(1) as that is far easier to read and look at.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
colinhackscommented, May 15, 2021

Good call, I agree with this. I’ll probably never remove support but I’ll steer people towards .min(1). Deprecated in #440.

1reaction
aliicommented, Nov 6, 2022

As a workaround, you could write .min(1, 'Username must be at least 1 character');

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove empty string in a list? - python - Stack Overflow
You can use filter , with None as the key function, which filters out all elements which are False ish (including empty strings)...
Read more >
Request: nonempty for string #63 - colinhacks/zod - GitHub
I'm using MUI for my forms and it requires my default input values to be an empty string. Of course that means an...
Read more >
Python | Remove empty strings from list of strings
remove () generally removes the first occurrence of an empty string and we keep iterating this process until no empty string is found...
Read more >
Python: Remove the nth index character from a nonempty string
Python Exercises, Practice and Solution: Write a Python program to remove the nth index character from a nonempty string.
Read more >
String - Robot Framework
A library for string manipulation and verification. String is Robot Framework's standard library for manipulating strings (e.g. Replace ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found