explodinglabs / jsonrpcserver

Process incoming JSON-RPC requests in Python
MIT License
186 stars 40 forks source link

Support for custom parameters' validators #234

Closed antispam2002 closed 1 year ago

antispam2002 commented 2 years ago

Currently, the parameters' validation is bound to

    try:
        signature(func).bind(*extract_args(request, context), **extract_kwargs(request))
    except TypeError as exc:
        return Left(InvalidParamsResult(str(exc)))
    return Right(func)

in dispatcher.py

This validation checks if the method's signature is compatible with provided parameters. However, there is no easy way to interfere in this validation, e.g. to provide own error messages, etc.

Would be very nice to have a way to specify some custom parameters' validation callable/class/etc when annotating a method with @method decorator.

bcb commented 2 years ago

Yes - great idea. I will actually add this this week, for version 6.

bcb commented 1 year ago

Added to version 6