-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 validator ignores 0 assuming the field is not provided #734
Comments
Haha... This actually is a "required" problem because it seems that 0 means the value is not provided. |
The same for empty string. Are there any examples with the case when string is required but might be empty? |
you can use gt as a work around e.g
|
Hello @hamidr sorry I’ve let this issue linger been rather busy lately. so this has been asked and covered many times in separate issue but to reiterate. If you read the “required” documentation carefully you will note it states it validates that the value isn’t it’s types default. So “required” is working as intended. Go does not have a notion of uninitialized variables and so the default is always the types default. Go also does not have a nice way to denote an optional variable like rusts “Option” either but there are 2 options in Go:
I hope this clarifies things :) |
Package version: v10
Issue:
Hey, folks :)
Required validator ignores 0 assuming the field is not provided.
This seems to be a default value issue.
I guess it can't be fixed?
Code sample, to showcase or reproduce:
The text was updated successfully, but these errors were encountered: