govalidator
govalidator copied to clipboard
Empty string does not validate as stringlength in the new version
Hi everyone: A struct defined like this:
type Input struct {
Keyword string `valid:"stringlength(3|64)"`
}
What I expect is:
Keyword == "" --> valid
Keyword == "e" --> invalid
Keyword == "eee" --> valid
It is worked in the version v0.0.0-20190424111038-f61b66f89f4a But after updated to version v0.0.0-20200108200545-475eaeb16496, the empty string does not validate
Keyword == "" --> invalid
I found it was the break change due to switch from isEmptyValue
to isFieldSet
So I want to know, is the design of stringlength
has changed ? Or just a bug ?
If the design has changed, how do I implement the requirement "empty or specified length scope of string" ?
Thanks a lot for any help !
I met the same problem with you. Did you solve this problem? 你解决这个问题了吗?求解。
We are also having this issue? any update on this?
@elvinchan chan Add required to solve the problem.
type Input struct {
Keyword string `valid:"stringlength(3|64) , required"`
}
Hello guys! I forked this package cause owner disappeared. Hope, he will be back, but it would be easier to merge these changes back if he is back Link to my repo: create issue there and we'll discuss it.
We also have this problem.