gosv

package module
v0.0.0-...-3751bb2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 6 Imported by: 0

README

Ketan: Struct Validator for Go

A simple validator for struct.

usage

Import the package then call the function, ie. validate(myStruct). See the example at ./test/main.go

func return

The validation return map[string]ValidationError where each key of the map represents a struct field name containing error.

type validationError

Struct with the following fields:

  1. Error error // the error message
  2. Code string // code of the rule given to the field
  3. ExptdValue string // expected value for the field
  4. GivenValue interface{} // given value for the field

Documentation

Overview

Go Struct Validator

Go Struct Validator Default Validator

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterValidator

func RegisterValidator(tag string, validatorF validator)

simply add or remove tag validator

func UnregisterValidator

func UnregisterValidator(tag string)

func Validate

func Validate(input interface{}, nameSpaces ...string) map[string]ValidationError

main func, validation of each elem

Types

type ValidationError

type ValidationError struct {
	Error      error
	Code       string
	ExptdValue string
	GivenValue interface{}
}

error format, exported for casting purpose

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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