Documentation
¶
Index ¶
- Constants
- Variables
- func CheckFloatRange(val float64, min *float64, max *float64) error
- func CheckIntRange(val int64, min *int64, max *int64) error
- func CheckRange[T constraints.Ordered](val T, min *T, max *T) error
- func DecodeBuffer(buf []byte, chain SchemaChain) (any, error)
- func DecodeBufferNamed(buf []byte, chain SchemaNamedChain) (any, error)
- func EncodeValue(val any, chain SchemaChain) ([]byte, error)
- func EncodeValueNamed(val any, chain SchemaNamedChain) ([]byte, error)
- func PtrToInt64[T constraints.Integer](val T) *int64
- func RegisterSchemaType(typeName string, builder func(*SchemaJSON) Schema)
- func UnregisterSchemaType(typeName string)
- func ValidateBuffer(buf []byte, chain SchemaChain) error
- type ErrorCode
- type MissingKeyErrorDetails
- type Nullable
- type RangeErrorDetails
- type SRepeatSchema
- type Schema
- func BuildSchema(js *SchemaJSON) Schema
- func SBytes(width int) Schema
- func SColor(nullable bool) Schema
- func SDate(nullable bool, from, to time.Time) Schema
- func SDateRange(nullable bool, from, to *time.Time) Schema
- func SEmail(optional bool) Schema
- func SEnum(fieldNames []string, nullable bool) Schema
- func SLang(optional bool) Schema
- func SMap(nested ...Schema) Schema
- func SMapUnordered(mappedSchemas map[string]Schema) Schema
- func SMapUnorderedOptional(mappedSchemas map[string]Schema) Schema
- func SStringExact(expected string) Schema
- func SStringLen(width int) Schema
- func SType(tag typetags.Type) Schema
- func SURI(optional bool) Schema
- func SVariableBytes() Schema
- func SVariableMap(nested ...Schema) Schema
- func SVariableString() Schema
- type SchemaAny
- type SchemaBool
- type SchemaBytes
- type SchemaChain
- type SchemaEnumNamedList
- type SchemaError
- type SchemaFloat32
- type SchemaFloat64
- type SchemaGeneric
- type SchemaInt8
- type SchemaInt16
- func (s SchemaInt16) Decode(seq *access.SeqGetAccess) (any, error)
- func (s SchemaInt16) Encode(put *access.PutAccess, val any) error
- func (s SchemaInt16) IsNullable() bool
- func (s SchemaInt16) Range(min, max *int64) Schema
- func (s SchemaInt16) RangeValues(min, max int64) Schema
- func (s SchemaInt16) Validate(seq *access.SeqGetAccess) error
- type SchemaInt32
- func (s SchemaInt32) Decode(seq *access.SeqGetAccess) (any, error)
- func (s SchemaInt32) Encode(put *access.PutAccess, val any) error
- func (s SchemaInt32) IsNullable() bool
- func (s SchemaInt32) Range(min, max *int64) Schema
- func (s SchemaInt32) RangeValues(min, max int64) Schema
- func (s SchemaInt32) Validate(seq *access.SeqGetAccess) error
- type SchemaInt64
- func (s SchemaInt64) DateRange(from, to *time.Time) Schema
- func (s SchemaInt64) DateRangeValues(from, to time.Time) Schema
- func (s SchemaInt64) Decode(seq *access.SeqGetAccess) (any, error)
- func (s SchemaInt64) Encode(put *access.PutAccess, val any) error
- func (s SchemaInt64) IsNullable() bool
- func (s SchemaInt64) Range(min, max *int64) Schema
- func (s SchemaInt64) RangeValues(min, max int64) Schema
- func (s SchemaInt64) Validate(seq *access.SeqGetAccess) error
- type SchemaJSON
- type SchemaMap
- type SchemaMapRepeat
- type SchemaMapUnordered
- type SchemaMultiCheckNamesSchema
- type SchemaNamedChain
- type SchemaNumber
- func (s SchemaNumber) Decode(seq *access.SeqGetAccess) (any, error)
- func (s SchemaNumber) DecodeValidate(seq *access.SeqGetAccess, decodeAlways bool) (any, error)
- func (s SchemaNumber) Encode(put *access.PutAccess, val any) error
- func (s SchemaNumber) IsNullable() bool
- func (s SchemaNumber) Validate(seq *access.SeqGetAccess) error
- type SchemaString
- func (s SchemaString) CheckFunc(code ErrorCode, expected string, test func(payloadStr string) bool) Schema
- func (s SchemaString) Decode(seq *access.SeqGetAccess) (any, error)
- func (s SchemaString) DefaultDecodeValue(decodeDefault string) SchemaString
- func (s SchemaString) Encode(put *access.PutAccess, val any) error
- func (s SchemaString) IsNullable() bool
- func (s SchemaString) Match(expected string) Schema
- func (s SchemaString) Optional() SchemaString
- func (s SchemaString) Pattern(expr string) Schema
- func (s SchemaString) Prefix(prefix string) Schema
- func (s SchemaString) Suffix(suffix string) Schema
- func (s SchemaString) Validate(seq *access.SeqGetAccess) error
- func (s SchemaString) WithWidth(n int) SchemaString
- type SchemaTypeOnly
- type SizeExact
- type StringErrorDetails
- type TupleSchema
- type TupleSchemaNamed
Constants ¶
const ( SchemaAnyName = "SchemaAny" SchemaStringName = "SchemaString" SchemaBytesName = "SchemaBytes" SchemaMapName = "SchemaMap" SchemaTypeOnlyName = "SchemaTypeOnly" SchemaBoolName = "SchemaBool" SchemaInt8Name = "SchemaInt8" SchemaInt16Name = "SchemaInt16" SchemaInt32Name = "SchemaInt32" SchemaInt64Name = "SchemaInt64" SchemaFloat32Name = "SchemaFloat32" SchemaFloat64Name = "SchemaFloat64" SchemaNamedChainName = "SchemaNamedChain" SchemaMapUnorderedName = "SchemaMapUnordered" SchemaMultiCheckNamesSchemaNamed = "SchemaMultiCheckNamesSchemaNamed" SchemaDateName = "SchemaDate" SchemaEnumNamedListName = "SchemaEnumNamedList" SchemaNumberName = "SchemaNumber" ChainName = "SchemaChain" TupleSchemaName = "TupleSchema" TupleSchemaNamedName = "TupleSchemaNamed" SRepeatSchemaName = "SRepeatSchema" SchemaMapRepeatName = "SchemaMapRepeat" )
Variables ¶
var ( SBool Schema = SchemaBool{} SInt8 Schema = SchemaInt8{} SInt16 SchemaInt16 = SchemaInt16{} SInt32 SchemaInt32 = SchemaInt32{} SInt64 SchemaInt64 = SchemaInt64{} SFloat32 Schema = SchemaFloat32{} SFloat64 Schema = SchemaFloat64{} SNumber Schema = SchemaNumber{} SNumberString Schema = SchemaNumber{DecodeAsString: true} SNullBool Schema = SchemaBool{Nullable: true} SNullInt8 Schema = SchemaInt8{Nullable: true} SNullInt16 Schema = SchemaInt16{Nullable: true} SNullInt32 Schema = SchemaInt32{Nullable: true} SNullInt64 Schema = SchemaInt64{Nullable: true} SNullFloat32 Schema = SchemaFloat32{Nullable: true} SNullFloat64 Schema = SchemaFloat64{Nullable: true} SString SchemaString = SchemaString{Width: 0} SAny = SchemaAny{} )
var ErrTypeMisMatch error = errors.New("Type Mismatch")
var ErrUnsupportedType error = errors.New("Unsuported Type")
Functions ¶
func CheckFloatRange ¶
For float64
func CheckRange ¶
func CheckRange[T constraints.Ordered](val T, min *T, max *T) error
CheckRange validates val against optional min/max bounds. Returns a RangeErrorDetails if out of range, otherwise nil.
func DecodeBuffer ¶
func DecodeBuffer(buf []byte, chain SchemaChain) (any, error)
func DecodeBufferNamed ¶
func DecodeBufferNamed(buf []byte, chain SchemaNamedChain) (any, error)
func EncodeValue ¶
func EncodeValue(val any, chain SchemaChain) ([]byte, error)
func EncodeValueNamed ¶
func EncodeValueNamed(val any, chain SchemaNamedChain) ([]byte, error)
func PtrToInt64 ¶
func PtrToInt64[T constraints.Integer](val T) *int64
func RegisterSchemaType ¶
func RegisterSchemaType(typeName string, builder func(*SchemaJSON) Schema)
RegisterSchemaType registers a custom Schema builder for a given type name.
Usage:
schema.RegisterSchemaType("MyCustomType", func(js schema.SchemaJSON) schema.Schema {
// Build your own Schema based on js
return SString.WithWidth(js.Width) // or any custom logic
})
Notes:
- Type names are case-sensitive ("MyCustomType" ≠ "mycustomtype").
- Panics if the type name is already registered (built-in or custom).
- Use UnregisterSchemaType to remove a custom type.
This allows users to extend BuildSchema with their own typetags without modifying the core switch.
func UnregisterSchemaType ¶
func UnregisterSchemaType(typeName string)
UnregisterSchemaType removes a previously registered custom Schema builder.
Usage:
schema.UnregisterSchemaType("MyCustomType")
If the type name is not found, the function does nothing.
func ValidateBuffer ¶
func ValidateBuffer(buf []byte, chain SchemaChain) error
Types ¶
type ErrorCode ¶
type ErrorCode int
const ( ErrUnknown ErrorCode = iota ErrInvalidFormat // decoding failed due to invalid format ErrUnexpectedEOF // sequence ended unexpectedly while advancing or reading ErrConstraintViolated // validation rule failed (width, type mismatch, nullable constraint) ErrEncode // String‑specific validation codes ErrStringMismatch // generic string mismatch ErrStringPrefix // prefix check failed ErrStringSuffix // suffix check failed ErrStringPattern // regex/pattern check failed ErrStringMatch // exact match failed ErrStringEmail // email format validation failed ErrStringURL // URL/URI format validation failed ErrStringLang // language tag format validation failed // Numeric validation codes ErrOutOfRange // integer value out of allowed range ErrDateOutOfRange // timestamp/date value out of allowed range )
type MissingKeyErrorDetails ¶
type MissingKeyErrorDetails struct {
Key string
}
func (MissingKeyErrorDetails) Error ¶
func (e MissingKeyErrorDetails) Error() string
type RangeErrorDetails ¶
type RangeErrorDetails[T constraints.Ordered] struct { Min *T Max *T Actual T }
RangeErrorDetails represents a structured range violation for any ordered type.
func (RangeErrorDetails[T]) Error ¶
func (r RangeErrorDetails[T]) Error() string
type SRepeatSchema ¶
type SRepeatSchema struct {
Schemas []Schema
// contains filtered or unexported fields
}
func SRepeatRange ¶
func SRepeatRange(minimum *int64, maximum *int64, schemas ...Schema) SRepeatSchema
func (SRepeatSchema) Decode ¶
func (s SRepeatSchema) Decode(seq *access.SeqGetAccess) (any, error)
func (SRepeatSchema) IsNullable ¶
func (s SRepeatSchema) IsNullable() bool
func (SRepeatSchema) Validate ¶
func (s SRepeatSchema) Validate(seq *access.SeqGetAccess) error
type Schema ¶
type Schema interface {
Validate(seq *access.SeqGetAccess) error
Decode(seq *access.SeqGetAccess) (any, error)
Encode(put *access.PutAccess, val any) error
IsNullable() bool
}
func BuildSchema ¶
func BuildSchema(js *SchemaJSON) Schema
BuildSchema constructs a Schema instance from a SchemaJSON definition.
It inspects the `Type` field of the provided SchemaJSON and returns the corresponding Schema. Built-in typetags include:
- "bool" → SBool / SNullBool
- "int8" → SInt8 / SNullInt8
- "int16" → SInt16 with optional Range
- "int32" → SInt32 with optional Range
- "int64" → SInt64 with optional Range
- "date" → SDate with optional DateFrom/DateTo
- "float32" → SFloat32 / SNullFloat32
- "float64" → SFloat64 / SNullFloat64
- "string" → SString with optional width, exact, prefix, suffix, pattern
- "email" → SEmail
- "uri" → SURI
- "lang" → SLang
- "bytes" → SBytes / SVariableBytes
- "any" → SAny
- "tuple" → STuple / STupleNamed / STupleVal (with flatten/variableLength)
- "repeat" → SRepeat
- "map" → SMap
- "mapUnordered" → SMapUnordered / SMapUnorderedOptional
- "mapRepeat" → SMapRepeatRange
- "multicheck" → SMultiCheckNames
- "enum" → SEnum
- "color" → SColor
If the type is not recognized, BuildSchema checks the custom registry (see RegisterSchemaType) before panicking.
Usage:
js := SchemaJSON{Type: "string", Width: 20, Prefix: "ID_"}
s := BuildSchema(js)
s now validates strings up to 20 chars starting with "ID_"
Custom type example:
schema.RegisterSchemaType("MyCustomType", func(js schema.SchemaJSON) schema.Schema {
return SString.Pattern("[A-Z]{3}[0-9]{2}")
})
custom := BuildSchema(SchemaJSON{Type: "MyCustomType"})
Notes:
- Type names are case-sensitive.
- Nullable fields are respected where applicable.
- Min/Max apply to numeric typetags.
- DateFrom/DateTo must be RFC3339 strings.
- For "mapUnordered", FieldNames and Schema must align in length.
- For "mapRepeat", Schema must contain exactly two entries.
func SMapUnordered ¶
func SMapUnorderedOptional ¶
func SStringExact ¶
func SStringLen ¶
func SVariableBytes ¶
func SVariableBytes() Schema
func SVariableMap ¶
func SVariableString ¶
func SVariableString() Schema
type SchemaAny ¶
type SchemaAny struct {
DecodeAsOrderedMap bool
}
func SchemaAnyOrdered ¶
func SchemaAnyOrdered() SchemaAny
func (SchemaAny) IsNullable ¶
type SchemaBool ¶
type SchemaBool struct{ Nullable bool }
Primitives
func (SchemaBool) Decode ¶
func (s SchemaBool) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaBool) IsNullable ¶
func (s SchemaBool) IsNullable() bool
func (SchemaBool) Validate ¶
func (s SchemaBool) Validate(seq *access.SeqGetAccess) error
type SchemaBytes ¶
type SchemaBytes struct{ Width int }
func (SchemaBytes) Decode ¶
func (s SchemaBytes) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaBytes) IsNullable ¶
func (s SchemaBytes) IsNullable() bool
func (SchemaBytes) Validate ¶
func (s SchemaBytes) Validate(seq *access.SeqGetAccess) error
type SchemaChain ¶
type SchemaChain struct {
Schemas []Schema
}
func SChain ¶
func SChain(schemas ...Schema) SchemaChain
type SchemaEnumNamedList ¶
SchemaEnumNamedList constrains an index to a list of names, encoded in 2 bytes. Perfect for radio groups or select dropdowns.
func (SchemaEnumNamedList) Decode ¶
func (s SchemaEnumNamedList) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaEnumNamedList) Encode ¶
func (s SchemaEnumNamedList) Encode(put *access.PutAccess, val any) error
func (SchemaEnumNamedList) IsNullable ¶
func (s SchemaEnumNamedList) IsNullable() bool
func (SchemaEnumNamedList) Validate ¶
func (s SchemaEnumNamedList) Validate(seq *access.SeqGetAccess) error
type SchemaError ¶
func NewSchemaError ¶
func NewSchemaError(code ErrorCode, name, field string, pos int, inner error) *SchemaError
func (*SchemaError) Error ¶
func (v *SchemaError) Error() string
func (*SchemaError) Unwrap ¶
func (v *SchemaError) Unwrap() error
type SchemaFloat32 ¶
type SchemaFloat32 struct{ Nullable bool }
func (SchemaFloat32) Decode ¶
func (s SchemaFloat32) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaFloat32) IsNullable ¶
func (s SchemaFloat32) IsNullable() bool
func (SchemaFloat32) Validate ¶
func (s SchemaFloat32) Validate(seq *access.SeqGetAccess) error
type SchemaFloat64 ¶
type SchemaFloat64 struct{ Nullable bool }
func (SchemaFloat64) Decode ¶
func (s SchemaFloat64) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaFloat64) IsNullable ¶
func (s SchemaFloat64) IsNullable() bool
func (SchemaFloat64) Validate ¶
func (s SchemaFloat64) Validate(seq *access.SeqGetAccess) error
type SchemaGeneric ¶
type SchemaGeneric struct {
ValidateFunc func(seq *access.SeqGetAccess) error
DecodeFunc func(seq *access.SeqGetAccess) (any, error)
EncodeFunc func(put *access.PutAccess, val any) error
NullableCheck func() bool
}
func (SchemaGeneric) Decode ¶
func (f SchemaGeneric) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaGeneric) IsNullable ¶
func (f SchemaGeneric) IsNullable() bool
func (SchemaGeneric) Validate ¶
func (f SchemaGeneric) Validate(seq *access.SeqGetAccess) error
type SchemaInt8 ¶
type SchemaInt8 struct{ Nullable bool }
func (SchemaInt8) Decode ¶
func (s SchemaInt8) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaInt8) IsNullable ¶
func (s SchemaInt8) IsNullable() bool
func (SchemaInt8) Validate ¶
func (s SchemaInt8) Validate(seq *access.SeqGetAccess) error
type SchemaInt16 ¶
type SchemaInt16 struct{ Nullable bool }
func (SchemaInt16) Decode ¶
func (s SchemaInt16) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaInt16) IsNullable ¶
func (s SchemaInt16) IsNullable() bool
func (SchemaInt16) Range ¶
func (s SchemaInt16) Range(min, max *int64) Schema
func (SchemaInt16) RangeValues ¶
func (s SchemaInt16) RangeValues(min, max int64) Schema
func (SchemaInt16) Validate ¶
func (s SchemaInt16) Validate(seq *access.SeqGetAccess) error
type SchemaInt32 ¶
type SchemaInt32 struct{ Nullable bool }
func (SchemaInt32) Decode ¶
func (s SchemaInt32) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaInt32) IsNullable ¶
func (s SchemaInt32) IsNullable() bool
func (SchemaInt32) Range ¶
func (s SchemaInt32) Range(min, max *int64) Schema
func (SchemaInt32) RangeValues ¶
func (s SchemaInt32) RangeValues(min, max int64) Schema
func (SchemaInt32) Validate ¶
func (s SchemaInt32) Validate(seq *access.SeqGetAccess) error
type SchemaInt64 ¶
type SchemaInt64 struct{ Nullable bool }
func (SchemaInt64) DateRangeValues ¶
func (s SchemaInt64) DateRangeValues(from, to time.Time) Schema
func (SchemaInt64) Decode ¶
func (s SchemaInt64) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaInt64) IsNullable ¶
func (s SchemaInt64) IsNullable() bool
func (SchemaInt64) Range ¶
func (s SchemaInt64) Range(min, max *int64) Schema
func (SchemaInt64) RangeValues ¶
func (s SchemaInt64) RangeValues(min, max int64) Schema
func (SchemaInt64) Validate ¶
func (s SchemaInt64) Validate(seq *access.SeqGetAccess) error
type SchemaJSON ¶
type SchemaJSON struct {
Type string `json:"type"`
FieldNames []string `json:"fieldNames,omitempty"`
Schema []SchemaJSON `json:"schema,omitempty"`
Nullable bool `json:"nullable,omitempty"`
VariableLength bool `json:"variableLength,omitempty"`
Flatten bool `json:"flatten,omitempty"`
// Constraint helpers
Width int `json:"width,omitempty"`
Min *int64 `json:"min,omitempty"`
Max *int64 `json:"max,omitempty"`
Exact string `json:"exact,omitempty"`
Prefix string `json:"prefix,omitempty"`
Suffix string `json:"suffix,omitempty"`
Pattern string `json:"pattern,omitempty"`
DateFrom string `json:"dateFrom,omitempty"`
DateTo string `json:"dateTo,omitempty"`
DecodeDefault string `json:"decodeDefault,omitempty"`
// Extra metadata for UI or other purposes
Extra map[string]any `json:"extra,omitempty"`
}
type SchemaMap ¶
NOTE: SchemaMap expects keys in sorted order. Validation will fail if map keys are unordered or mismatched.
func (SchemaMap) Decode ¶
func (s SchemaMap) Decode(seq *access.SeqGetAccess) (any, error)
Decode reads a SchemaMap from the sequence into an OrderedMapAny.
func (SchemaMap) Encode ¶
Encode writes an OrderedMapAny into the sequence according to the SchemaMap.
func (SchemaMap) IsNullable ¶
type SchemaMapRepeat ¶
func SMapRepeat ¶
func SMapRepeat(key Schema, value Schema) SchemaMapRepeat
func SMapRepeatRange ¶
func SMapRepeatRange(key Schema, value Schema, minimum, maximum *int64) SchemaMapRepeat
func (SchemaMapRepeat) Decode ¶
func (s SchemaMapRepeat) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaMapRepeat) Encode ¶
func (s SchemaMapRepeat) Encode(put *access.PutAccess, val any) error
func (SchemaMapRepeat) IsNullable ¶
func (s SchemaMapRepeat) IsNullable() bool
func (SchemaMapRepeat) Validate ¶
func (s SchemaMapRepeat) Validate(seq *access.SeqGetAccess) error
type SchemaMapUnordered ¶
func (SchemaMapUnordered) Decode ¶
func (s SchemaMapUnordered) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaMapUnordered) Encode ¶
func (s SchemaMapUnordered) Encode(put *access.PutAccess, val any) error
func (SchemaMapUnordered) IsNullable ¶
func (s SchemaMapUnordered) IsNullable() bool
func (SchemaMapUnordered) Validate ¶
func (s SchemaMapUnordered) Validate(seq *access.SeqGetAccess) error
type SchemaMultiCheckNamesSchema ¶
SchemaMultiCheckNamesSchema is a convenience schema: every field is a SchemaBool.
func SMultiCheckNames ¶
func SMultiCheckNames(fieldNames []string) SchemaMultiCheckNamesSchema
func (SchemaMultiCheckNamesSchema) Decode ¶
func (s SchemaMultiCheckNamesSchema) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaMultiCheckNamesSchema) Encode ¶
func (s SchemaMultiCheckNamesSchema) Encode(put *access.PutAccess, val any) error
func (SchemaMultiCheckNamesSchema) IsNullable ¶
func (s SchemaMultiCheckNamesSchema) IsNullable() bool
func (SchemaMultiCheckNamesSchema) Validate ¶
func (s SchemaMultiCheckNamesSchema) Validate(seq *access.SeqGetAccess) error
type SchemaNamedChain ¶
type SchemaNamedChain struct {
SchemaChain
FieldNames []string
}
type SchemaNumber ¶
func (SchemaNumber) Decode ¶
func (s SchemaNumber) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaNumber) DecodeValidate ¶
func (s SchemaNumber) DecodeValidate(seq *access.SeqGetAccess, decodeAlways bool) (any, error)
func (SchemaNumber) IsNullable ¶
func (s SchemaNumber) IsNullable() bool
func (SchemaNumber) Validate ¶
func (s SchemaNumber) Validate(seq *access.SeqGetAccess) error
type SchemaString ¶
func (SchemaString) Decode ¶
func (s SchemaString) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaString) DefaultDecodeValue ¶
func (s SchemaString) DefaultDecodeValue(decodeDefault string) SchemaString
func (SchemaString) IsNullable ¶
func (s SchemaString) IsNullable() bool
func (SchemaString) Match ¶
func (s SchemaString) Match(expected string) Schema
func (SchemaString) Optional ¶
func (s SchemaString) Optional() SchemaString
func (SchemaString) Pattern ¶
func (s SchemaString) Pattern(expr string) Schema
func (SchemaString) Prefix ¶
func (s SchemaString) Prefix(prefix string) Schema
func (SchemaString) Suffix ¶
func (s SchemaString) Suffix(suffix string) Schema
func (SchemaString) Validate ¶
func (s SchemaString) Validate(seq *access.SeqGetAccess) error
func (SchemaString) WithWidth ¶
func (s SchemaString) WithWidth(n int) SchemaString
type SchemaTypeOnly ¶
func (SchemaTypeOnly) Decode ¶
func (s SchemaTypeOnly) Decode(seq *access.SeqGetAccess) (any, error)
func (SchemaTypeOnly) IsNullable ¶
func (s SchemaTypeOnly) IsNullable() bool
func (SchemaTypeOnly) Validate ¶
func (s SchemaTypeOnly) Validate(seq *access.SeqGetAccess) error
type StringErrorDetails ¶
func (StringErrorDetails) Error ¶
func (e StringErrorDetails) Error() string
type TupleSchema ¶
func STuple ¶
func STuple(Schema ...Schema) TupleSchema
func STupleVal ¶
func STupleVal(Schema ...Schema) TupleSchema
func STupleValFlatten ¶
func STupleValFlatten(Schema ...Schema) TupleSchema
func (TupleSchema) Decode ¶
func (s TupleSchema) Decode(seq *access.SeqGetAccess) (any, error)
func (TupleSchema) IsNullable ¶
func (s TupleSchema) IsNullable() bool
func (TupleSchema) Validate ¶
func (s TupleSchema) Validate(seq *access.SeqGetAccess) error
type TupleSchemaNamed ¶
type TupleSchemaNamed struct {
Schemas []Schema
FieldNames []string
Nullable bool
Flatten bool
VariableLength bool
}
func STupleNamed ¶
func STupleNamed(fieldNames []string, Schema ...Schema) TupleSchemaNamed
func STupleNamedVal ¶
func STupleNamedVal(fieldNames []string, Schema ...Schema) TupleSchemaNamed
Strict named tuple: exact field count
func STupleNamedValFlattened ¶
func STupleNamedValFlattened(fieldNames []string, Schema ...Schema) TupleSchemaNamed
Flexible named tuple: allows repeats/extra fields
func (TupleSchemaNamed) Decode ¶
func (s TupleSchemaNamed) Decode(seq *access.SeqGetAccess) (any, error)
func (TupleSchemaNamed) Encode ¶
func (s TupleSchemaNamed) Encode(put *access.PutAccess, val any) error
func (TupleSchemaNamed) IsNullable ¶
func (s TupleSchemaNamed) IsNullable() bool
func (TupleSchemaNamed) Validate ¶
func (s TupleSchemaNamed) Validate(seq *access.SeqGetAccess) error