Categorygithub.com/moonrhythm/validator
modulepackage
1.3.0
Repository: https://github.com/moonrhythm/validator.git
Documentation: pkg.go.dev

# README

validator

Validator is not validator, just a string error list helper :P

Why

f := flash()

if name == "" {
    f.AddError("name required")
}
if email == "" {
    f.AddError("email required")
}
if !govalidator.IsEmail(email) {
    f.AddError("invalid email")
}
if err := validatePassword(pass); err != nil {
    f.AddError("invalid password")
}
// ...
if f.HasError() {
    // ...
}

// no error

Then

v := validator.New() // this is not the validator :P

v.Must(name != "", "name required")
v.Must(email != "", "email required")
v.Must(govalidator.IsEmail(email), "invalid email")
v.Must(validatePassword(pass), "invalid password")
// ...
if !v.Valid() {
    // has error, ...
}

// no error

# Functions

IsError returns true if given error is validate error.
New creates new validator.

# Structs

Error is the validate error.
Validator type.