diff --git a/dynamic/errors.go b/dynamic/errors.go index f8260c3..9467bcf 100644 --- a/dynamic/errors.go +++ b/dynamic/errors.go @@ -17,6 +17,9 @@ const ErrNoServiceForHandler = cerr("no service found for this handler") // ErrMissingHandlerArgumentParam - missing params arguments for handler const ErrMissingHandlerArgumentParam = cerr("missing handler argument : parameter struct") +// ErrUnexpectedInput - input argument is not expected +const ErrUnexpectedInput = cerr("unexpected input struct") + // ErrMissingHandlerOutput - missing output for handler const ErrMissingHandlerOutput = cerr("handler must have at least 1 output") diff --git a/dynamic/spec.go b/dynamic/spec.go index 9e0871e..ee6fd06 100644 --- a/dynamic/spec.go +++ b/dynamic/spec.go @@ -44,6 +44,9 @@ func (s spec) checkInput(fnv reflect.Value) error { // no input -> ok if len(s.Input) == 0 { + if fnt.NumIn() > 0 { + return ErrUnexpectedInput + } return nil } diff --git a/dynamic/spec_test.go b/dynamic/spec_test.go index 535d9e3..0ce92bc 100644 --- a/dynamic/spec_test.go +++ b/dynamic/spec_test.go @@ -21,11 +21,11 @@ func TestInputCheck(t *testing.T) { Fn: func() {}, Err: nil, }, - // func can have any arguments if not specified + // func must have noarguments if none specified { Input: map[string]reflect.Type{}, Fn: func(int, string) {}, - Err: nil, + Err: ErrUnexpectedInput, }, // missing input struct in func {