Documentation ¶
Index ¶
- Variables
- func Bool(opts ...SchemaOption) *boolProcessor
- func Float(opts ...SchemaOption) *numberProcessor[float64]
- func Int(opts ...SchemaOption) *numberProcessor[int]
- func NewMapDataProvider[T any](m map[string]T) p.DataProvider
- func Ptr(schema ZogSchema) *pointerProcessor
- func Slice(schema ZogSchema, opts ...SchemaOption) *sliceProcessor
- func String(opts ...SchemaOption) *stringProcessor
- func Struct(schema Schema) *structProcessor
- func TestFunc(errCode zconst.ZogErrCode, validateFunc p.TestFunc) p.Test
- type Numeric
- type ParseCtx
- type ParsingOption
- type Schema
- type SchemaOption
- type Test
- type TestOption
- type TimeFunc
- type ZogErrList
- type ZogErrMap
- type ZogError
- type ZogSchema
Constants ¶
This section is empty.
Variables ¶
var Errors = errHelpers{}
Helper struct for dealing with zog errors. Beware this API may change
Functions ¶
func Float ¶
func Float(opts ...SchemaOption) *numberProcessor[float64]
creates a new float64 schema
func NewMapDataProvider ¶
func NewMapDataProvider[T any](m map[string]T) p.DataProvider
Creates a new map data provider
func Ptr ¶ added in v0.12.1
func Ptr(schema ZogSchema) *pointerProcessor
Ptr creates a pointer ZogSchema
func Slice ¶
func Slice(schema ZogSchema, opts ...SchemaOption) *sliceProcessor
func Struct ¶
func Struct(schema Schema) *structProcessor
Returns a new structProcessor which can be used to parse input data into a struct
Types ¶
type ParsingOption ¶
type ParsingOption = func(p *p.ZogParseCtx)
Options that can be passed to a `schema.Parse()` call
func WithCtxValue ¶
func WithCtxValue(key string, val any) ParsingOption
func WithErrFormatter ¶
func WithErrFormatter(fmter p.ErrFmtFunc) ParsingOption
type SchemaOption ¶ added in v0.12.0
type SchemaOption = func(s ZogSchema)
Options that can be passed to a `schema.New()` call
func WithCoercer ¶ added in v0.12.0
func WithCoercer(c conf.CoercerFunc) SchemaOption
type TestOption ¶
Options that can be passed to a test
func Message ¶
func Message(msg string) TestOption
Message is a function that allows you to set a custom message for the test.
func MessageFunc ¶
func MessageFunc(fn p.ErrFmtFunc) TestOption
MessageFunc is a function that allows you to set a custom message formatter for the test.
type TimeFunc ¶ added in v0.12.0
type TimeFunc func(opts ...SchemaOption) *timeProcessor
var Time TimeFunc = func(opts ...SchemaOption) *timeProcessor { t := &timeProcessor{ coercer: conf.Coercers.Time, } for _, opt := range opts { opt(t) } return t }
Returns a new Time Schema
func (TimeFunc) Format ¶ added in v0.12.0
func (t TimeFunc) Format(format string) SchemaOption
Sets the string format for the time schema Usage is: z.Time(z.Time.Format(time.RFC3339))
func (TimeFunc) FormatFunc ¶ added in v0.12.0
Sets the format function for the time schema Usage is:
z.Time(z.Time.FormatFunc(func(data string) (time.Time, error) { return time.Parse(time.RFC3339, data) }))
type ZogErrList ¶
type ZogErrList = p.ZogErrList
ZogErrList is a []ZogError returned from parsing primitive schemas