validation

package
v0.0.0-...-e7c6ebb Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: BSD-3-Clause Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidDigest

func IsValidDigest(hash string) bool

IsValidDigest returns true if the given string is a valid digest on the string level, i.e. it does not check whether we have actually seen the given hash but whether it complies with the format that we expect for a hash.

Types

type Validation

type Validation []string

Validation is a container to collect error messages during validation of a input with multiple fields.

func (*Validation) Errors

func (v *Validation) Errors() error

Errors returns a concatenation of all error values accumulated in validation or nil if there were no errors.

func (*Validation) Float64FormValue

func (v *Validation) Float64FormValue(r *http.Request, name string, defaultVal float64) float64

Float64FormValue does the same as Float64Value but extracts the value from the request object.

func (*Validation) Float64Value

func (v *Validation) Float64Value(name string, strVal string, defaultVal float64) float64

Float64Value parses the value given in strVal and returns it. If strVal is empty the default value is returned.

func (*Validation) Int64FormValue

func (v *Validation) Int64FormValue(r *http.Request, name string, defaultVal int64) int64

Int64FormValue does the same as Int64Value but extracts the value from the request object.

func (*Validation) Int64SliceFormValue

func (v *Validation) Int64SliceFormValue(r *http.Request, name string, defaultVal []int64) []int64

Int64SliceFormValue does the same as Int64SliceValue but extracts the given name from the request.

func (*Validation) Int64SliceValue

func (v *Validation) Int64SliceValue(name string, strVal string, defaultVal []int64) []int64

Int64SliceValue parses a comma-separated list of int values and returns them.

func (*Validation) Int64Value

func (v *Validation) Int64Value(name string, strVal string, defaultVal int64) int64

Int64Value parses the value given in strVal and returns it. If strVal is empty the default value is returned.

func (*Validation) QueryFormValue

func (v *Validation) QueryFormValue(r *http.Request, name string) map[string][]string

QueryFormValue extracts a URL-encoded query from the form values and decodes it. If the named field was not available in the given request an empty paramtools.ParamSet is returned. If an error occurs it will be added to the error list of the validation object.

func (*Validation) StrFormValue

func (v *Validation) StrFormValue(r *http.Request, name string, val *string, options []string, defaultVal string)

StrFormValue does the same as StrValue but extracts the given name from the request via r.FormValue(..).

func (*Validation) StrValue

func (v *Validation) StrValue(name string, val *string, options []string, defaultVal string)

StrValue validates a string value against containment in a set of options. Argument:

name: name of the field being validated.
val: value to be validated.
options: list of options, one of which value can contain.
defaultVal: default value in case val is empty. Can be equal to "".

If there is a problem an error message will be added to the Validation object.

Jump to

Keyboard shortcuts

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