jsonrpcserver icon indicating copy to clipboard operation
jsonrpcserver copied to clipboard

Support for custom parameters' validators

Open antispam2002 opened this issue 3 years ago • 1 comments

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.

antispam2002 avatar May 23 '22 15:05 antispam2002

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

bcb avatar May 23 '22 21:05 bcb

Added to version 6

bcb avatar Feb 26 '23 11:02 bcb