go-ozzo / ozzo-validation

An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.
MIT License
3.73k stars 224 forks source link

validation.IN cannot parse byte arrays #72

Closed ChielTimmermans closed 4 years ago

ChielTimmermans commented 5 years ago

The validation to check if a value can be found in a given list can not parse byte arrays. I think it is pretty easy to fix. for now i will create a custom function

qiangxue commented 4 years ago

Could you provide an example to explain the problem?

ChielTimmermans commented 4 years ago

When i run the following code

    data := []byte("example")
    err := validation.Validate(data,
        validation.In([]byte("test"), []byte("test2")),
    )
    fmt.Println(err)

I get the error:

panic: runtime error: comparing uncomparable type []uint8

qiangxue commented 4 years ago

Fixed. Thanks!