bouncer/internal/schema/validate.go

18 lines
291 B
Go
Raw Normal View History

2023-06-24 01:53:56 +02:00
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
}