This is AccelByte Justice Golang Input Validation package. This package is extending functionality from govalidator and add some additional rule to it.
import validator "github.com/AccelByte/justice-input-validation-go"
We can validate a struct that have validation tag literal with validateStruct() method
import validator "github.com/AccelByte/justice-input-validation-go"
// example of a request model
type requestModel struct {
Name string `valid:"displayName"`
Email string `valid:"email"`
}
reqData = requestModel{
Name: "Jhon Doe",
Email: "[email protected]",
}
// validating struct
if valid, err := validator.ValidateStruct(reqData); !valid || err {
// do something when reqData is invalid
}
"tag" : IsTag
"language" : IsLanguage
"topic" : IsTopic
"displayName" : IsDisplayName
"personName" : IsPersonName
"uuid4WithoutHyphens" : IsUUID4WithoutHyphens
"permissionResource" : IsPermissionResource
"path" : IsPath
"url" : IsURL
"uri" : IsURI
"dateTime" : IsDateTime
"date" : IsDate
"jwt" : IsJWT
"password" : IsPassword
"email" : IsEmail
"codeChallenge" : IsCodeChallenge
"notContainWhitespace" : IsNotContainWhitespace
"containWhitespace" : IsContainWhitespace
"country" : IsCountry
"namespace" : IsNamespace
And of course this package is not limiting the functionality that came from govalidator package, you can use all available validation rules that supported by govalidator package.