validation

package
v0.0.0-...-cbb82f6 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2016 License: MIT Imports: 4 Imported by: 0

README

Validation

Installation

$ go get github.com/dogenzaka/gin-tools/validation

Requirements

Tests

Example

func main() {

    r := gin.Default()
    
    r.Use(validation.ValidatePathParam("name", validator.MinLength{1}, validator.MaxLength{32}))
    r.GET("/user/:name", func(c *gin.Context) {
        name := c.Params.ByName("name")
        message := "Hello "+name
        c.String(200, message)
    })

    r.Run(":8080")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatePathParam

func ValidatePathParam(name string, vs ...Validator) gin.HandlerFunc

ValidatePathParam validate for path parameter

func ValidateRequestBody

func ValidateRequestBody(vs ...Validator) gin.HandlerFunc

ValidateRequestBody validate for request body

func ValidateRequestHeader

func ValidateRequestHeader(name string, vs ...Validator) gin.HandlerFunc

ValidateRequestHeader validate for request header

func ValidateRequestParam

func ValidateRequestParam(name string, vs ...Validator) gin.HandlerFunc

ValidateRequestParam validate for request parameter

Types

type Validator

type Validator interface {
	Validate(param string) bool
}

Validator interface provides a "Validate" method

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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