A validation library in Pure Go.
- Customized error messages for your validation rules
- Easy to write custom rules
- Define your own validation method
- Fast (Visit our benchmark page for more details)
To see the list of options, you can refer to the options page.
go get github.com/Jh123x/go-validate
package main
import (
"github.com/Jh123x/go-validate/options"
"github.com/Jh123x/go-validate/validator"
)
func main(){
lazyValidator := validator.NewLazyValidator()
err := lazyValidator.WithOptions(
options.IsNotEmpty("").WithError(fmt.Errorf("empty string")), // Fails and returns error.
options.IsLength([]string{}, 0, 3).WithError(fmt.Errorf("empty string")), // Will not be evaluated.
).Validate()
if err != nil {
// handle error
...
}
}
An example usage is shown in the code snippet above. To see a full list of options, you can refer to the options page.
Please create an issue if you have any:
- Questions
- Suggestions
- Find any bugs
- Want to point out any mistakes
- Code a new feature or fix a bug.
- Add tests for the new feature or the bug you fixed.
- Fill up the pull request template.
- Create a pull request.
- Wait for the CI to pass.
- Wait for the maintainer to review your code.
- Wait for the maintainer to merge your code.
- Add other types of validators for different use cases.
- Add more comprehensive documentations.