Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"required" validation is confusing #13

Open
rogpeppe opened this issue Oct 31, 2019 · 0 comments
Open

"required" validation is confusing #13

rogpeppe opened this issue Oct 31, 2019 · 0 comments

Comments

@rogpeppe
Copy link

It's easy to think that required means that a field must be provided. We have plenty of examples where required is used on a string value, even though it's a no-op when used on string values.

required is also non-orthogonal to nonzero, which does a similar job.
We could just use nonzero everywhere, but nonzero is itself somewhat confusing, because when used on a pointer to a numeric type, it's not entirely clear whether it is referring to the pointer or the numeric value.

As a future breaking change, we could perhaps remove nonzero entirely and make required be exactly the same as the current nonzero validation. This would bring the tags more into line with the conventions used by another validator package.

// TODO this functionality is arguably confusingly non-orthogonal
// to that of nonzero. The behavior of nonzero is also arguably
// confusing for pointers to numeric types, so as a future breaking
// change, we could change required to be essentially the same
// as nonzero and remove nonzero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant