validator

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2019 License: Apache-2.0 Imports: 6 Imported by: 11

README

justice-input-validation-go

This is Accelbyte Justice Golang Input Validation package. This package is extending functionality from govalidator and add some additional rule to it.

Usage

Importing package
import validator "github.com/AccelByte/justice-input-validation-go"
Validating struct from request data model

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: "jhon@mail.com",
}

// validating struct
if valid, err := validator.ValidateStruct(reqData); !valid || err {
    // do something when reqData is invalid
}
 
List of available validators with its corresponding function that defined in rules.go file
"tag"                   : IsTag
"language"              : IsLanguage
"topic"                 : IsTopic
"displayName"           : IsDisplayName
"userDisplayName"       : IsUserDisplayName
"uuid4WithoutHyphens"   : IsUUID4WithoutHyphens
"orderNumber"           : IsOrderNumber
"dockerImage"           : IsDockerImage
"permissionResource"    : IsPermissionResource
"path"                  : IsPath
"url"                   : IsURL
"memorySize"            : IsMemorySize
"time"                  : IsTime
"dob"                   : IsDate
"jwt"                   : IsJWT
"password"              : IsPassword
"emailOWASP"            : IsOWASPEmail

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAlphaNumeric

func IsAlphaNumeric(str string, params ...string) bool

func IsDate

func IsDate(str string) bool

func IsDisplayName

func IsDisplayName(str string) bool

func IsDockerImage

func IsDockerImage(str string) bool

func IsIn

func IsIn(str string, params ...string) bool

func IsJWT

func IsJWT(str string) bool

func IsLanguage

func IsLanguage(str string) bool

func IsLowerCase

func IsLowerCase(str string) bool

func IsMemorySize

func IsMemorySize(str string) bool

func IsNumeric

func IsNumeric(str string) bool

func IsOWASPEmail

func IsOWASPEmail(str string) bool

func IsOrderNumber

func IsOrderNumber(str string) bool

func IsPassword

func IsPassword(str string) bool

func IsPath

func IsPath(str string) bool

func IsPermissionResource

func IsPermissionResource(str string) bool

func IsTag

func IsTag(str string) bool

func IsTime

func IsTime(str string) bool

func IsTopic

func IsTopic(str string) bool

func IsURL

func IsURL(str string) bool

func IsUUID4WithoutHyphens

func IsUUID4WithoutHyphens(str string) bool

func IsUserDisplayName

func IsUserDisplayName(str string) bool

func ValidateStruct

func ValidateStruct(s interface{}) (bool, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL