Skip to content

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

License

Notifications You must be signed in to change notification settings

moonrhythm/validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages