validate

package
v0.0.0-...-2b1c11c Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: BSD-3-Clause Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomBinder

type CustomBinder struct{}

CustomBinder custom binding functionality

func (*CustomBinder) Bind

func (cb *CustomBinder) Bind(i interface{}, c echo.Context) error

Bind does the default echo binding

type CustomValidator

type CustomValidator struct {
	// contains filtered or unexported fields
}

CustomValidator to add additional validation of external input

func NewValidator

func NewValidator() *CustomValidator

NewValidator returns a new CustomValidator

func (*CustomValidator) Validate

func (cv *CustomValidator) Validate(i interface{}) error

Validate adds the additional validator checking

type CustomValueBinder

type CustomValueBinder struct {
	*echo.ValueBinder
	// contains filtered or unexported fields
}

CustomValueBinder will help tie form errors to form struct fields in error reporting.

func FormFieldBinder

func FormFieldBinder(c echo.Context, form any) *CustomValueBinder

FormFieldBinder will return a custom value binder

func (*CustomValueBinder) NewBindingError

func (c *CustomValueBinder) NewBindingError(sourceParam string, values []string, message interface{}, internalError error) error

NewBindingError creates new instance of binding error but swaps the `sourceParam` with the struct field name if the `sourceParam` value matches a struct tag on a given form field.

type InputErrors

type InputErrors gobwebs.Map

InputErrors map of many InputError's

func GetInputErrors

func GetInputErrors(errors []error) InputErrors

GetInputErrors generates an input errors map. Expects a slice of echo.BindingErrors (returned from echo.ValueBinder.BindErrors()

func NewInputErrors

func NewInputErrors() InputErrors

NewInputErrors makes an InputError map with default _global_

func (InputErrors) Error

func (i InputErrors) Error() string

Error error interface

type Map

type Map = gobwebs.Map

Map is an alias for gobwebs.Map

type StaticFunc

type StaticFunc func(c echo.Context) Map

StaticFunc is a function signature for functions processed to populate template contexts

type Template

type Template struct {
	// contains filtered or unexported fields
}

Template defines the template registry struct

func NewTemplate

func NewTemplate() *Template

NewTemplate returns a *Template instance

func (*Template) AddFuncs

func (t *Template) AddFuncs(funcs template.FuncMap)

AddFuncs adds template functions to the rendering template

func (*Template) AddStaticFunc

func (t *Template) AddStaticFunc(f StaticFunc)

AddStaticFunc adds a function to be called when building the default template context variables.

func (*Template) AddStaticVar

func (t *Template) AddStaticVar(key string, value any) error

AddStaticVar adds a constant variable to the template context

func (*Template) CloneBase

func (t *Template) CloneBase() (*template.Template, error)

Clone will clone the `t.templateBase` Template to ensure all added static funcs and variables are available

func (*Template) LoadTemplates

func (t *Template) LoadTemplates(path string, tfs fs.FS) error

LoadTemplates parses templates given the glob pattern path

func (*Template) New

func (t *Template) New(tfs fs.FS, filenames ...string) (*template.Template, error)

New will return a clone of `t.templateBase` having already parsed the given files. This is used when you don't want to use the larger mix of already processed templates.

func (*Template) Render

func (t *Template) Render(w io.Writer, name string, data any, c echo.Context) error

Render implements e.Renderer interface

func (*Template) RenderTemplate

func (t *Template) RenderTemplate(
	tmpl *template.Template, w io.Writer, name string, data any, c echo.Context) error

RenderTemplate takes a *template.Template object and populates it's context with the static values already provided by `t`.

func (*Template) Templates

func (t *Template) Templates() *template.Template

Templates returns local *template.Template object

Jump to

Keyboard shortcuts

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