Class: JSONRPC::Validator
- Inherits:
-
Object
- Object
- JSONRPC::Validator
- Defined in:
- lib/jsonrpc/validator.rb
Overview
Validates JSON-RPC 2.0 requests, notifications and batches
The Validator handles parameter validation for JSON-RPC requests by checking method signatures against registered procedure definitions using Dry::Validation contracts.
Instance Method Summary collapse
-
#initialize(logger: JSONRPC.configuration.logger) ⇒ Validator
constructor
Initializes the Validator.
-
#validate(batch_or_request) ⇒ JSONRPC::Error, ...
Validates a single request, notification or a batch.
Constructor Details
#initialize(logger: JSONRPC.configuration.logger) ⇒ Validator
Initializes the Validator
22 23 24 |
# File 'lib/jsonrpc/validator.rb', line 22 def initialize(logger: JSONRPC.configuration.logger) @logger = logger end |
Instance Method Details
#validate(batch_or_request) ⇒ JSONRPC::Error, ...
Validates a single request, notification or a batch
42 43 44 45 46 47 48 49 |
# File 'lib/jsonrpc/validator.rb', line 42 def validate(batch_or_request) case batch_or_request when BatchRequest validate_batch_params(batch_or_request) when Request, Notification validate_request_params(batch_or_request) end end |