zed

package module
v0.0.0-...-b402b9d Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolSchema

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

func Bool

func Bool(err string) *BoolSchema

func (*BoolSchema) ToSchema

func (s *BoolSchema) ToSchema() *ogen.Schema

func (*BoolSchema) Validate

func (s *BoolSchema) Validate(v any, _ SchemaValidationFlag) (out bool, e error)

func (*BoolSchema) ValidateGeneric

func (s *BoolSchema) ValidateGeneric(v any, flags SchemaValidationFlag) (any, error)

type DateTimeSchema

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

func DateTime

func DateTime(err string) *DateTimeSchema

func (*DateTimeSchema) EpochUnit

func (s *DateTimeSchema) EpochUnit(interval EpochUnit) *DateTimeSchema

func (*DateTimeSchema) Layout

func (s *DateTimeSchema) Layout(layout string) *DateTimeSchema

func (*DateTimeSchema) ToSchema

func (s *DateTimeSchema) ToSchema() *ogen.Schema

func (*DateTimeSchema) Validate

func (s *DateTimeSchema) Validate(v any, _ SchemaValidationFlag) (out time.Time, e error)

func (*DateTimeSchema) ValidateGeneric

func (s *DateTimeSchema) ValidateGeneric(v any, flags SchemaValidationFlag) (any, error)

type EpochUnit

type EpochUnit uint8
const (
	EpochNanosecond EpochUnit = 1 << iota
	EpochMicrosecond
	EpochMillisecond
	EpochSecond
)

type NumSchema

type NumSchema[T integer | float] struct {
	// contains filtered or unexported fields
}

func Float32

func Float32(err string) *NumSchema[float32]

func Float64

func Float64(err string) *NumSchema[float64]

func Int

func Int(err string) *NumSchema[int]

func Int8

func Int8(err string) *NumSchema[int8]

func Int16

func Int16(err string) *NumSchema[int16]

func Int32

func Int32(err string) *NumSchema[int32]

func Int64

func Int64(err string) *NumSchema[int64]

func Uint8

func Uint8(err string) *NumSchema[uint8]

func Uint16

func Uint16(err string) *NumSchema[uint16]

func Uint32

func Uint32(err string) *NumSchema[uint32]

func (*NumSchema[T]) Max

func (s *NumSchema[T]) Max(val int64, exclusive bool, err string) *NumSchema[T]

func (*NumSchema[T]) Min

func (s *NumSchema[T]) Min(val int64, exclusive bool, err string) *NumSchema[T]

func (*NumSchema[T]) ToSchema

func (s *NumSchema[T]) ToSchema() (os *ogen.Schema)

func (*NumSchema[T]) Validate

func (s *NumSchema[T]) Validate(v any, flags SchemaValidationFlag) (out T, e error)

func (*NumSchema[T]) ValidateGeneric

func (s *NumSchema[T]) ValidateGeneric(v any, flags SchemaValidationFlag) (any, error)

type Schema

type Schema[TOut any] interface {
	Validate(val any, flags SchemaValidationFlag) (TOut, error)
}

type SchemaTrait

type SchemaTrait interface {
	ValidateGeneric(v any, flags SchemaValidationFlag) (any, error)
	ToSchema() *ogen.Schema
}

type SchemaValidationFlag

type SchemaValidationFlag uint8
const (
	AbortEarly SchemaValidationFlag = 1 << iota
)

func (SchemaValidationFlag) Has

func (f SchemaValidationFlag) Has(_f SchemaValidationFlag) bool

type StringSchema

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

func String

func String(err string) *StringSchema

func (*StringSchema) MaxLen

func (s *StringSchema) MaxLen(l uint64, err string) *StringSchema

func (*StringSchema) MinLen

func (s *StringSchema) MinLen(l uint64, err string) *StringSchema

func (*StringSchema) Pattern

func (s *StringSchema) Pattern(p string, err string) *StringSchema

func (*StringSchema) ToSchema

func (s *StringSchema) ToSchema() (os *ogen.Schema)

func (*StringSchema) Validate

func (s *StringSchema) Validate(v any, flags SchemaValidationFlag) (out string, e error)

func (*StringSchema) ValidateGeneric

func (s *StringSchema) ValidateGeneric(v any, flags SchemaValidationFlag) (any, error)

type StructCompileError

type StructCompileError struct {
	Path string
	Err  error
}

func (*StructCompileError) Error

func (fe *StructCompileError) Error() string

type StructFieldFlag

type StructFieldFlag uint8
const (
	FieldRequired StructFieldFlag = 1 << iota
)

func (StructFieldFlag) Has

func (f StructFieldFlag) Has(_f StructFieldFlag) bool

type StructSchema

type StructSchema[T any] struct {
	// contains filtered or unexported fields
}

func Struct

func Struct(err string) *StructSchema[map[string]any]

func StructFor

func StructFor[T any](err string) *StructSchema[T]

func StructForE

func StructForE[T any](err string) (*StructSchema[T], error)

func (*StructSchema[T]) AddField

func (s *StructSchema[T]) AddField(name string, schema SchemaTrait, flags StructFieldFlag) *StructSchema[T]

func (*StructSchema[T]) ToSchema

func (s *StructSchema[T]) ToSchema() (os *ogen.Schema)

func (*StructSchema[T]) Validate

func (s *StructSchema[T]) Validate(m any, flags SchemaValidationFlag) (out T, e error)

func (*StructSchema[T]) ValidateGeneric

func (s *StructSchema[T]) ValidateGeneric(v any, flags SchemaValidationFlag) (any, error)

type UUIDSchema

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

func UUID

func UUID(err string) *UUIDSchema

func (*UUIDSchema) ToSchema

func (s *UUIDSchema) ToSchema() *ogen.Schema

func (*UUIDSchema) Validate

func (s *UUIDSchema) Validate(v any, _ SchemaValidationFlag) (out uuid.UUID, e error)

func (*UUIDSchema) ValidateGeneric

func (s *UUIDSchema) ValidateGeneric(v any, flags SchemaValidationFlag) (any, error)

type ValidationError

type ValidationError struct {
	Path string
	Err  error
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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