Documentation
¶
Overview ¶
Package validation validates Lambda inputs and outputs against JSON Schema.
Index ¶
- func Validate(ctx context.Context, payload, schema any, options Options) (any, error)
- func WrapHandler[I, T, R any](inbound, outbound *Schema, handler func(context.Context, T) (R, error)) func(context.Context, I) (R, error)
- type CompileOptions
- type Compiler
- type Issue
- type Options
- type RegexError
- type RegexOptions
- type Schema
- type SchemaCompilationError
- type SchemaValidationError
- type Validator
- type ValidatorFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
Validate compiles for this call, then extracts and validates the payload. Use Compile once for warm-invocation reuse.
func WrapHandler ¶
func WrapHandler[I, T, R any](inbound, outbound *Schema, handler func(context.Context, T) (R, error)) func(context.Context, I) (R, error)
WrapHandler validates a cloned inbound event and a successful outbound response. Only inbound validation applies an envelope; business errors and panics propagate.
Types ¶
type CompileOptions ¶
type CompileOptions struct {
Regex RegexOptions
Formats map[string]func(any) error
// NumberFormats applies callbacks to JSON numbers rather than strings.
NumberFormats map[string]func(any) error
// ExternalRefs registers URL-keyed documents in lexical URL order.
ExternalRefs map[string]any
// ExternalSchemas registers documents by $id in slice order, after ExternalRefs.
// Use it when nested resource identities depend on registration order.
ExternalSchemas []any
}
type Options ¶
type Options struct {
CompileOptions
Envelope string
QueryOptions []jmespath.Option
Compiler Compiler
}
type RegexError ¶
RegexError identifies an operational match failure, not an invalid payload.
func (*RegexError) Error ¶
func (e *RegexError) Error() string
func (*RegexError) Unwrap ¶
func (e *RegexError) Unwrap() error
type RegexOptions ¶
type RegexOptions struct {
MatchTimeout time.Duration
// A positive value sets the stack bound; a negative value removes it.
MaxBacktrackingStackSize int
}
RegexOptions configures operational limits without changing pattern syntax. Zero values use the engine's defaults: no timeout and a 100,000-entry stack.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema retains a reusable validator and optional compiled extraction expression.
type SchemaCompilationError ¶
type SchemaCompilationError struct{ Err error }
func (*SchemaCompilationError) Error ¶
func (e *SchemaCompilationError) Error() string
func (*SchemaCompilationError) Unwrap ¶
func (e *SchemaCompilationError) Unwrap() error
type SchemaValidationError ¶
func (*SchemaValidationError) Error ¶
func (e *SchemaValidationError) Error() string
func (*SchemaValidationError) Unwrap ¶
func (e *SchemaValidationError) Unwrap() error