Skip to content

Instantly share code, notes, and snippets.

@phuctm97
Last active September 24, 2019 16:28
Show Gist options
  • Save phuctm97/707858a34e6891649642d68ec9311428 to your computer and use it in GitHub Desktop.
Save phuctm97/707858a34e6891649642d68ec9311428 to your computer and use it in GitHub Desktop.
Go RESTful Series
package users
import (
"errors"
"regexp"
"github.com/the-evengers/go-restful/common"
)
// ... other stuff ...
// ValidateUser validates a user data and returns validation errors or nil.
func ValidateUser(user *User) error {
errs := make([]error, 0)
// ... validations ...
// Return errors or nil.
if len(errs) == 0 {
return nil
}
return common.Errors(errs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment