updated the interface to return a Error struct and modified the function and tests accordingly

This commit is contained in:
AshwiniK-protean
2025-03-13 11:16:45 +05:30
parent 0488eccc3b
commit e9cc670e3d
8 changed files with 88 additions and 80 deletions

View File

@@ -5,12 +5,18 @@ import (
"net/url"
)
// Error struct for validation errors
type Error struct {
Path string
Message string
}
// Validator interface for schema validation
type Validator interface {
Validate(ctx context.Context, url url.URL, payload []byte) (bool, error)
Validate(ctx context.Context, url *url.URL, payload []byte) (bool, Error)
}
// ValidatorProvider interface for creating validators
type ValidatorProvider interface {
New(ctx context.Context, config map[string]string) (map[string]Validator, error)
New(ctx context.Context, config map[string]string) (map[string]Validator, Error)
}