validate

package
v0.0.0-...-685dc72 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 4 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultValidator

func DefaultValidator(v reflect.Value, c path.ContextPath) report.Report

DefaultValidator checks if the type implements the validator interface and calls the validate function if it does, returning the report.

func FieldName

func FieldName(s StructField, tag string) string

func Validate

func Validate(thing interface{}, tag string) report.Report

Validate walks the structs, slices, and pointers in thing and calls any Validate(path.ContextPath) report.Report functions defined on the types, aggregating the results.

func ValidateCustom

func ValidateCustom(thing interface{}, tag string, customValidator CustomValidator) report.Report

ValidateCustom validates thing using the custom validation function supplied. Most users will not need this and should use Validate() instead.

Types

type CustomValidator

type CustomValidator func(v reflect.Value, c path.ContextPath) report.Report

type StructField

type StructField struct {
	reflect.StructField
	Value reflect.Value
}

StructField is an extension of go's reflect.StructField that also includes the value.

func GetFields

func GetFields(v reflect.Value) []StructField

GetFields takes a value of a struct and flattens all embedded structs in it. If any fields are interfaces, it "dereferences" the interface to its underlying type.

Jump to

Keyboard shortcuts

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