Last active
August 29, 2015 14:23
-
-
Save seregayoga/b30e48b09b7b32c42eaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"gopkg.in/bluesuncorp/validator.v5" | |
"log" | |
) | |
type MyStruct struct { | |
StringField string `validate:"required"` | |
BoolField bool `validate:"required"` | |
} | |
func main() { | |
validate := validator.New("validate", validator.BakedInValidators) | |
myStruct := MyStruct{ | |
StringField: "some string", | |
BoolField: false, | |
} | |
errs := validate.Struct(myStruct) | |
log.Println(errs) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's not really documented anywhere, but the "required" should not be added to a boolean field.
go's boolean is not tristate, because of that it is always set and so "required" is not really necessary