array

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

schema/array/rules.go

schema/array/schema.go

schema/array/validate.go

Index

Constants

View Source
const (
	CodeRequired = "array.required"
	CodeType     = "array.type"
	CodeMin      = "array.min"
	CodeMax      = "array.max"
	CodeItem     = "array.item"

	CodeLen = "array.len"
	CodeEq  = "array.eq"
	CodeNe  = "array.ne"
	CodeGt  = "array.gt"
	CodeGte = "array.gte"
	CodeLt  = "array.lt"
	CodeLte = "array.lte"

	CodeUnique = "array.unique"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ItemValidator

type ItemValidator[E any] func(context *engine.Context, value ast.Value) (E, bool)

type Schema

type Schema[E any] struct {
	// contains filtered or unexported fields
}

func New

func New[E any]() *Schema[E]

func (*Schema[E]) Custom

func (s *Schema[E]) Custom(ruleValue ruleset.RuleFn[[]E]) *Schema[E]

func (*Schema[E]) Default

func (s *Schema[E]) Default(value []E) *Schema[E]

func (*Schema[E]) DefaultFunc

func (s *Schema[E]) DefaultFunc(fn func() []E) *Schema[E]

func (*Schema[E]) Eq

func (s *Schema[E]) Eq(length int) *Schema[E]

func (*Schema[E]) Gt

func (s *Schema[E]) Gt(length int) *Schema[E]

func (*Schema[E]) Gte

func (s *Schema[E]) Gte(length int) *Schema[E]

func (*Schema[E]) Items

func (s *Schema[E]) Items(validator ItemValidator[E]) *Schema[E]

func (*Schema[E]) Len

func (s *Schema[E]) Len(length int) *Schema[E]

func (*Schema[E]) Lt

func (s *Schema[E]) Lt(length int) *Schema[E]

func (*Schema[E]) Lte

func (s *Schema[E]) Lte(length int) *Schema[E]

func (*Schema[E]) Max

func (s *Schema[E]) Max(length int) *Schema[E]

func (*Schema[E]) Min

func (s *Schema[E]) Min(length int) *Schema[E]

func (*Schema[E]) Ne

func (s *Schema[E]) Ne(length int) *Schema[E]

func (*Schema[E]) OutputType

func (s *Schema[E]) OutputType() reflect.Type

func (*Schema[E]) Required

func (s *Schema[E]) Required() *Schema[E]

func (*Schema[E]) Unique

func (s *Schema[E]) Unique() *Schema[E]

func (*Schema[E]) UniqueByEqual

func (s *Schema[E]) UniqueByEqual(equal func(left E, right E) bool) *Schema[E]

func (*Schema[E]) UniqueByHash

func (s *Schema[E]) UniqueByHash(hash func(value E) string) *Schema[E]

func (*Schema[E]) Validate

func (s *Schema[E]) Validate(input any, optionList ...schema.Option) ([]E, error)

func (*Schema[E]) ValidateAny

func (s *Schema[E]) ValidateAny(input any, options schema.Options) (any, error)

Directories

Path Synopsis
schema/array/rule/eq.go
schema/array/rule/eq.go

Jump to

Keyboard shortcuts

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