Documentation ¶
Index ¶
- Constants
- Variables
- func FormatUser(user *models.User)
- func GetInstance() *validator.Validate
- func GetInvalidFieldsFromErr(err error) ([]string, error)
- func GetInvalidFieldsValues(err error) (map[string]interface{}, error)
- func HashPassword(password string) string
- func ValidateField(structure interface{}, field, value string) bool
- func ValidateFieldEmail(email string) bool
- func ValidateFieldPassword(password string) bool
- func ValidateFieldTag(tag string) bool
- func ValidateFieldUsername(username string) bool
- func ValidateStruct(data interface{}) ([]string, error)
- func ValidateStructFields(data interface{}) (map[string]interface{}, error)
- func ValidateVar(data interface{}, tag string) ([]string, error)
- type Validator
Constants ¶
const ( // TagRegexp is the tag used to validate a regexp. TagRegexp = "regexp" // TagUsername is the tag used to validate ShellHub's username. TagUsername = "username" )
Variables ¶
var ErrInvalidError = errors.New("this error is not from a field validation")
var ErrInvalidFields = errors.New("invalid fields")
Functions ¶
func FormatUser ¶ added in v0.8.0
FormatUser apply some formation rules to a models.User and encrypt the password.
func GetInstance ¶ added in v0.10.9
func GetInstance() *validator.Validate
func GetInvalidFieldsFromErr ¶ added in v0.10.9
GetInvalidFieldsFromErr gets the invalids frields from a error returned by Struct function.
func GetInvalidFieldsValues ¶ added in v0.9.2
GetInvalidFieldsValues receive a structure validation error and return a map with invalid fields and values.
func HashPassword ¶ added in v0.8.0
func ValidateField ¶ added in v0.9.1
ValidateField validates if a structure's field is valid.
func ValidateFieldEmail ¶ added in v0.9.0
ValidateFieldEmail validate the data for the field Email from structure models.UserData.
func ValidateFieldPassword ¶ added in v0.9.0
ValidateFieldPassword validate the data for the field Password from structure models.UserPassword.
func ValidateFieldTag ¶ added in v0.9.0
ValidateFieldTag validate the data for the field Tag from structure models.Device.
func ValidateFieldUsername ¶ added in v0.9.0
ValidateFieldUsername validate the data for the field Username from structure models.UserData.
func ValidateStruct ¶ added in v0.7.3
func ValidateStructFields ¶ added in v0.9.2
func ValidateVar ¶ added in v0.7.3
Types ¶
type Validator ¶ added in v0.10.9
type Validator struct {
Validate *validator.Validate
}
func New ¶ added in v0.10.9
func New() *Validator
New creates a new ShellHub validator.
The ShellHub validator contains validations rules to name, username, email, password, etc.