schema: tests passing.

This commit is contained in:
fiatjaf
2025-11-23 14:11:37 -03:00
parent 18887727d1
commit ff5655ac55
3 changed files with 113 additions and 28 deletions

View File

@@ -7,12 +7,12 @@ import (
"fiatjaf.com/nostr/schema"
)
func ValidateAgainstSchema(ctx context.Context, evt nostr.Event) (bool, string) {
v := schema.NewDefaultValidator()
v.FailOnUnknown = true
err := v.ValidateEvent(evt)
if err != nil {
return true, err.Error()
func ValidateAgainstSchema(v schema.Validator) func(ctx context.Context, evt nostr.Event) (bool, string) {
return func(ctx context.Context, evt nostr.Event) (bool, string) {
err := v.ValidateEvent(evt)
if err != nil {
return true, err.Error()
}
return false, ""
}
return false, ""
}