asaskevich / govalidator

[Go] Package of validators and sanitizers for strings, numerics, slices and structs
MIT License
6.02k stars 556 forks source link

uuid validation is not working anymore? #259

Open lgcassab opened 6 years ago

lgcassab commented 6 years ago

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) // <--- FAILS!
assert.True(t, isValid)

}

func Test_UUID2_Struct(t *testing.T) {

type TestRequest struct {
    ID uuid.UUID `valid:"uuid,required"`
}

uuid := uuid.NewV4()
assert.NotNil(t, uuid)

request := &TestRequest{
    uuid,
}

isValid, err := govalidator.ValidateStruct(request)
assert.Nil(t, err) // <--- FAILS!
assert.True(t, isValid)

}

pmilanez commented 6 years ago

Failed for me too. I've checked and this UUID is a valid one: Valid, The UUID is db87461e-19b2-47ef-8531-98006921aaa1, It is UUID Version 4.

sergeyglazyrindev commented 2 years ago

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.