File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,32 @@ Simple JSON-RPC params validator that use Symfony validator component
1111
1212## How to use
1313
14+ In order to be validated, a JSON-RPC method must :
15+ - Implements ` JsonRpcMethodInterface ` from [ ` yoanm/jsonrpc-server-sdk ` ] ( https://github.com/yoanm/php-jsonrpc-server-sdk )
16+ - Implements [ ` MethodWithValidatedParamsInterface ` ] ( ./src/Infra/JsonRpcParamsValidator.php )
17+
18+ Then use it as following :
19+ ``` php
20+ use Symfony\Component\Validator\ValidatorBuilder;
21+ use Yoanm\JsonRpcParamsSymfonyValidator\Infra\JsonRpcParamsValidator;
22+
23+ // Create the validator
24+ $paramsValidator = new JsonRpcParamsValidator(
25+ (new ValidatorBuilder())->getValidator()
26+ );
27+
28+ // Validate a given JSON-RPC method instance against a JSON-RPC request
29+ $violationList = $paramsValidator->validate($jsonRpcRequest, $jsonRpcMethod);
30+ ```
31+
32+ Each violations will have the following format :
33+ ``` php
34+ [
35+ 'path' => 'property_path',
36+ 'message' => 'violation message',
37+ 'code' => 'violation_code'
38+ ]
39+ ```
1440
1541## Contributing
1642See [ contributing note] ( ./CONTRIBUTING.md )
You can’t perform that action at this time.
0 commit comments