Coder Social home page Coder Social logo

justice-input-validation-go's Introduction

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: "[email protected]",
}

// 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
"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.

justice-input-validation-go's People

Contributors

angelo-chan avatar anggorodewanto avatar bahrunnur avatar antonsusilo7 avatar hvlcrs avatar thoriqsatriya avatar rjjatson avatar

Watchers

James Cloos avatar  avatar  avatar Fahri Baharudin avatar  avatar

justice-input-validation-go's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.