validate

package
v0.289.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Example (RangeInt)
package main

import (
	"go.llib.dev/frameless/pkg/validate"
)

func main() {
	type T struct {
		V int `range:"0..100"`
	}

	validate.Value(T{V: 42})  // no error
	validate.Value(T{V: -1})  // validate.Error
	validate.Value(T{V: 101}) // validate.Error
}
Example (RangeIntMulti)
package main

import (
	"go.llib.dev/frameless/pkg/validate"
)

func main() {
	type T struct {
		Num1 int `range:"0..100"`
		Num2 int `range:"0..25,30..50"`
	}

	_ = validate.Value(T{})
}

Index

Examples

Constants

View Source
const ImplementationError errorkit.Error = "ImplementationError"

Variables

This section is empty.

Functions

func Struct

func Struct(v any, opts ...Option) error

func StructField

func StructField(sf reflect.StructField, field reflect.Value, opts ...Option) error

func Value

func Value(v any, opts ...Option) error

Types

type Error added in v0.288.0

type Error struct{ Cause error }

Error is a validation error, that represents an incorrect content.

func (Error) Error added in v0.288.0

func (err Error) Error() string

func (Error) Unwrap added in v0.288.0

func (err Error) Unwrap() error

type Option added in v0.287.0

type Option option.Option[config]

type ValidationError deprecated

type ValidationError = Error

Deprecated: use validate.Error instead

type Validator added in v0.287.0

type Validator interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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