Documentation
¶
Index ¶
- func CastTo[T any](data map[string]any, v *T) error
- func Normalize(data any) (any, error)
- func Process(schema Field, data any, mergeDefaults bool) (any, error)
- type AnyOfField
- type ArrayField
- type BoolField
- type Field
- func AnyOf(types ...Field) Field
- func Array(elem Field) Field
- func ArrayOf(elem Field) Field
- func Bool() Field
- func Float() Field
- func FromStruct(v any) (Field, error)
- func Int() Field
- func ListOf(elem Field) Field
- func Map(keyType, valueType Field) Field
- func String() Field
- func Structure(fields map[string]Field) Field
- type FloatField
- type IntField
- type ListField
- type MapField
- type StringField
- func (s *StringField) CastTo(target any) (any, error)
- func (s *StringField) Default(value any) Field
- func (s *StringField) GetDefault() any
- func (s *StringField) HasDefault() bool
- func (s *StringField) IsRequired() bool
- func (s *StringField) Required() Field
- func (s *StringField) Validate(value any) error
- type StructureField
- func (s *StructureField) CastTo(target any) (any, error)
- func (s *StructureField) Default(value any) Field
- func (s *StructureField) GetDefault() any
- func (s *StructureField) HasDefault() bool
- func (s *StructureField) IsRequired() bool
- func (s *StructureField) Required() Field
- func (s *StructureField) Validate(value any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AnyOfField ¶
type AnyOfField struct {
// contains filtered or unexported fields
}
AnyOfField for anyOf
func (*AnyOfField) Default ¶
func (a *AnyOfField) Default(value any) Field
func (*AnyOfField) GetDefault ¶
func (a *AnyOfField) GetDefault() any
func (*AnyOfField) HasDefault ¶
func (a *AnyOfField) HasDefault() bool
func (*AnyOfField) IsRequired ¶
func (a *AnyOfField) IsRequired() bool
func (*AnyOfField) Required ¶
func (a *AnyOfField) Required() Field
func (*AnyOfField) Validate ¶
func (a *AnyOfField) Validate(value any) error
type ArrayField ¶
type ArrayField struct {
// contains filtered or unexported fields
}
ArrayField for handling slices
func (*ArrayField) Default ¶
func (a *ArrayField) Default(value any) Field
func (*ArrayField) GetDefault ¶
func (a *ArrayField) GetDefault() any
func (*ArrayField) HasDefault ¶
func (a *ArrayField) HasDefault() bool
func (*ArrayField) IsRequired ¶
func (a *ArrayField) IsRequired() bool
func (*ArrayField) Required ¶
func (a *ArrayField) Required() Field
func (*ArrayField) Validate ¶
func (a *ArrayField) Validate(value any) error
type BoolField ¶
type BoolField struct {
// contains filtered or unexported fields
}
func (*BoolField) GetDefault ¶
func (*BoolField) HasDefault ¶
func (*BoolField) IsRequired ¶
type Field ¶
type Field interface { Validate(value any) error Default(value any) Field CastTo(target any) (any, error) HasDefault() bool GetDefault() any Required() Field IsRequired() bool }
func FromStruct ¶
type FloatField ¶
type FloatField struct {
// contains filtered or unexported fields
}
func (*FloatField) Default ¶
func (f *FloatField) Default(value any) Field
func (*FloatField) GetDefault ¶
func (f *FloatField) GetDefault() any
func (*FloatField) HasDefault ¶
func (f *FloatField) HasDefault() bool
func (*FloatField) IsRequired ¶
func (f *FloatField) IsRequired() bool
func (*FloatField) Required ¶
func (f *FloatField) Required() Field
func (*FloatField) Validate ¶
func (f *FloatField) Validate(value any) error
type IntField ¶
type IntField struct {
// contains filtered or unexported fields
}
func (*IntField) GetDefault ¶
func (*IntField) HasDefault ¶
func (*IntField) IsRequired ¶
type ListField ¶
type ListField struct {
// contains filtered or unexported fields
}
ListField for listOf (indexed arrays)
func (*ListField) GetDefault ¶
func (*ListField) HasDefault ¶
func (*ListField) IsRequired ¶
type MapField ¶
type MapField struct {
// contains filtered or unexported fields
}
MapField for handling maps
func (*MapField) GetDefault ¶
func (*MapField) HasDefault ¶
func (*MapField) IsRequired ¶
type StringField ¶
type StringField struct {
// contains filtered or unexported fields
}
func (*StringField) Default ¶
func (s *StringField) Default(value any) Field
func (*StringField) GetDefault ¶
func (s *StringField) GetDefault() any
func (*StringField) HasDefault ¶
func (s *StringField) HasDefault() bool
func (*StringField) IsRequired ¶
func (s *StringField) IsRequired() bool
func (*StringField) Required ¶
func (s *StringField) Required() Field
func (*StringField) Validate ¶
func (s *StringField) Validate(value any) error
type StructureField ¶
type StructureField struct {
// contains filtered or unexported fields
}
func (*StructureField) Default ¶
func (s *StructureField) Default(value any) Field
func (*StructureField) GetDefault ¶
func (s *StructureField) GetDefault() any
func (*StructureField) HasDefault ¶
func (s *StructureField) HasDefault() bool
func (*StructureField) IsRequired ¶
func (s *StructureField) IsRequired() bool
func (*StructureField) Required ¶
func (s *StructureField) Required() Field
func (*StructureField) Validate ¶
func (s *StructureField) Validate(value any) error
Click to show internal directories.
Click to hide internal directories.