govalidator
govalidator copied to clipboard
[Go] Package of validators and sanitizers for strings, numerics, slices and structs
``` type Item struct { Bt int `valid:"range(1|100)"` } func main() { t := Item{-1} ok, err := govalidator.ValidateStruct(t) fmt.Println(ok, err) } ``` output:Bt: Validator range(1|100) doesn't support kind int;
This is actually an enhancement request. If the maintainer likes to add this enhancement, I am up for it. :)
fatal error: concurrent map read and map write goroutine 2399752 [running]: runtime.throw(0xb2bbd7, 0x21) /mnt/shared/go/src/runtime/panic.go:605 +0x95 fp=0xc60cb5c3c0 sp=0xc60cb5c3a0 pc=0x42d1f5 runtime.mapaccess2_faststr(0xa7d800, 0xc4201b3da0, 0xa124ec, 0x8, 0x0, 0x0) /mnt/shared/go/src/runtime/hashmap_fast.go:324 +0x47a fp=0xc60cb5c418 sp=0xc60cb5c3c0 pc=0x40dbaa innotechx.com/net-copycat-audit/vendor/github.com/asaskevich/govalidator.typeCheck(0xa4a9e0,...
`IsNull()` uses `strings.TrimSpace()` better than `len()`
How I can validate text only with string ? I wanna validate validate text with string.
func Test_UUID_Struct(t *testing.T) { type TestRequest struct { ID uuid.UUID `valid:"uuid,required"` } uuid := uuid.FromStringOrNil("db87461e-19b2-47ef-8531-98006921aaa1") request := &TestRequest{ uuid, } isValid, err := govalidator.ValidateStruct(request) assert.Nil(t, err) //
Username string `valid:"matches(^[0-9]{3}$)"` success, Username string `valid:"matches(^[0-9]{3,5}$)"` fail! error: Username: The following validator is invalid or can't be applied to the field: "matches(^[0-9]{3"
Problem with capital/lower case struct field. Validator float doesn't support kind float32 for value
I have an a problem with validate float field in structure: ``` type Order struct { Total float32 `db:"total" json:"total" valid:"float,required"` } ``` My originally json looks like this: ```...
Validator fails to validate elements (structs) of a list when they have required fields. I have the following structs: type CustomerOption struct { Name string `valid:"required" json:"name"` Value string `json:"value"`...
Lets say I have a simple struct with a min and max field and I want to make sure that min < max. Does govalidator provide a means to do...