21 lines
344 B
Go
21 lines
344 B
Go
package schema
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/davecgh/go-spew/spew"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func Validate(ctx context.Context, schema *Schema, data map[string]any) error {
|
|
spew.Dump(data)
|
|
|
|
state := schema.Validate(ctx, data)
|
|
|
|
if len(*state.Errs) > 0 {
|
|
return errors.WithStack(NewInvalidDataError(*state.Errs...))
|
|
}
|
|
|
|
return nil
|
|
}
|