validator

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateStruct

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

Performs actual data validation using validator definitions on the struct

Types

type DefaultValidator

type DefaultValidator struct {
}

DefaultValidator does not perform any validations.

func (DefaultValidator) Validate

func (v DefaultValidator) Validate(val interface{}) (bool, error)

type EmailValidator

type EmailValidator struct {
}

EmailValidator checks if string is a valid email address.

func (EmailValidator) Validate

func (v EmailValidator) Validate(val interface{}) (bool, error)

type NumberValidator

type NumberValidator struct {
	Min int
	Max int
}

NumberValidator performs numerical value validation. Its limited to int type for simplicity.

func (NumberValidator) Validate

func (v NumberValidator) Validate(val interface{}) (bool, error)

type StringValidator

type StringValidator struct {
	Min int
	Max int
}

StringValidator validates string presence and/or its length.

func (StringValidator) Validate

func (v StringValidator) Validate(val interface{}) (bool, error)

type Validator

type Validator interface {
	// Validate method performs validation and returns result and optional error.
	Validate(interface{}) (bool, error)
}

Generic data validator.

Jump to

Keyboard shortcuts

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