requestvalidation

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: MIT Imports: 2 Imported by: 0

README

about

This package is a wrapper for the github.com/go-playground/validator package.

You can validate a request (by struct) and get a status ("success" or "error") and when error, a map[string][]string of errors as a response. This might be useful for a json-formatted api response.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RequestValidator

type RequestValidator struct {
	RequestValidatorInterface
	// contains filtered or unexported fields
}

func NewRequestValidator

func NewRequestValidator() *RequestValidator

func (*RequestValidator) Validate

func (r *RequestValidator) Validate(request interface{}) (ValidationResponse, error)

type RequestValidatorInterface

type RequestValidatorInterface interface {
	Validate(request interface{}) (ValidationResponse, error)
}

type ValidationResponse

type ValidationResponse struct {
	Status string              `json:"status"`
	Errors map[string][]string `json:"errors"`
}

Jump to

Keyboard shortcuts

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