Skip to content

go-carrot/validator v2.0.0

Latest
Compare
Choose a tag to compare
@BrandonRomano BrandonRomano released this 28 Aug 21:28

Now with the introduction of easy https://github.com/guregu/null support into this project, I've found the need to want to set a value null.

In the context of a API, I want to be able to send an empty parameter to denote a null value.

This will now yield an error (where it didn't prior to this version):

var name string
err := Validate([]*Value{
    {Result: &name, Name: "name", Input: ""},
})
// err != nil

If you intend to allow nullable values in a validation, you will now have to use the respective null.* value.

var name null.String
err := Validate([]*Value{
    {Result: &name, Name: "name", Input: ""},
})
// err == nil

Also, in this version bump, null values are automatically applied their TypeHandler (so no need to specify it manually anymore).

Also worth noting, that this library uses and expects https://gopkg.in/guregu/null.v3