utils

package
v0.0.0-...-936a01b Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PaginationTemplate = map[string]interface{}{
	"limit":  "int~Limit has to be a number",
	"offset": "int~Offset has to be a number",
}

PaginationTemplate contains validation for Pagination components

Functions

func DecodeValidRequest

func DecodeValidRequest(dst interface{}, temp map[string]interface{}, srcs ...interface{}) error

DecodeValidRequest validates input maps (From Query.URL, or decoded Json Body) against template and returns typed structure srcs can be list of either map[string]interface{} or map[string][]string

func LowerCaseKeys

func LowerCaseKeys(m map[string]interface{}) map[string]interface{}

LowerCaseKeys returns new map with keys changed to lowercase

func MergeMaps

func MergeMaps(maps ...map[string]interface{}) map[string]interface{}

MergeMaps Merges provided maps into one

func ZeroValue

func ZeroValue(x interface{}) bool

ZeroValue checks if value is a Zero value.

Types

type Pagination

type Pagination struct {
	Limit  int `schema:"limit" valid:"type(int)~Limit has to be a number"`
	Offset int `schema:"offset" valid:"type(int)~Offset has to be a number"`
}

Pagination defines type safe Pagination request components

Jump to

Keyboard shortcuts

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