validator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package validator provide types for validate query after parsing

Index

Constants

This section is empty.

Variables

View Source
var (
	// UnexpectedType is error that can func
	// 	func TypeIs[T any]()
	UnexpectedType = errors.New("Unexpected type")
)

Functions

This section is empty.

Types

type ValidateFunc

type ValidateFunc func(value interface{}) error

ValidateFunc desctibe a func that take parsed value and validate it

func MergeValidationsFunc

func MergeValidationsFunc(funcs ...ValidateFunc) ValidateFunc

type Validations

type Validations map[string]ValidateFunc

Validations describe map of query valiues with their validations

func (Validations) Validate

func (v Validations) Validate(
	field string,
	value interface{},
) error

Validate try to validate field by passing given object to ValidateFunc

If field not found return nil

Don't validate that value is nil

Jump to

Keyboard shortcuts

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