The OpenRPC document containing the methods whose calls we want validated.
import { petstore } from "@open-rpc/examples";
const petStoreMethodCallValidator = new MethodCallValidator(petstore);
// Go on and use it!
Private
ajvPrivate
documentThe OpenRPC document containing the methods whose calls we want validated.
Validates a particular method call against the OpenRPC definition for the method.
the name of the method in the OpenRPC Document.
the param values that you want validated.
an array of parameter validation errors, or if there are none, an empty array. if the method name is invalid, a [[MethodNotFoundError]] is returned.
import { petstore } from "@open-rpc/examples";
const petStoreMethodCallValidator = new MethodCallValidator(petstore);
const errors = petStoreMethodCallValidator.validate("list_pets", []);
// errors.length === 0
A class to assist in validating method calls to an OpenRPC-based service. Generated Clients, Servers, and many others may want to expose the interface provided by an OpenRPC document. In doing so, use this class to easily create a re-useable validator for a particular method.