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