updated the interface to return a Error struct and modified the function and tests accordingly
This commit is contained in:
@@ -11,11 +11,11 @@ import (
|
||||
type ValidatorProvider struct{}
|
||||
|
||||
// New initializes a new Verifier instance.
|
||||
func (vp ValidatorProvider) New(ctx context.Context, config map[string]string) (map[string]definition.Validator, error) {
|
||||
func (vp ValidatorProvider) New(ctx context.Context, config map[string]string) (map[string]definition.Validator, definition.Error) {
|
||||
// Create a new Validator instance with the provided configuration
|
||||
validators, err := validator.New(ctx, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if err != (definition.Error{}) {
|
||||
return nil, definition.Error{Path: "", Message: err.Message}
|
||||
}
|
||||
|
||||
// Convert the map to the expected type
|
||||
@@ -24,8 +24,8 @@ func (vp ValidatorProvider) New(ctx context.Context, config map[string]string) (
|
||||
result[key] = val
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return result, definition.Error{}
|
||||
}
|
||||
|
||||
// Provider is the exported symbol that the plugin manager will look for.
|
||||
var Provider definition.ValidatorProvider = ValidatorProvider{}
|
||||
var Provider definition.ValidatorProvider = &ValidatorProvider{}
|
||||
|
||||
Reference in New Issue
Block a user