MCPcopy
hub / github.com/cloudflare/capnweb / validateResolvedValue

Function validateResolvedValue

packages/capnweb-validate/src/internal/core.ts:767–790  ·  view source on GitHub ↗
(
  value: unknown,
  validator: Validator,
  path: PropertyPath,
  side: WrapSide,
  mode: ValidationMode
)

Source from the content-addressed store, hash-verified

765}
766
767function validateResolvedValue(
768 value: unknown,
769 validator: Validator,
770 path: PropertyPath,
771 side: WrapSide,
772 mode: ValidationMode
773): unknown {
774 // Only the receiver validates. Returns are received by the client, so it
775 // checks them; the server is the sender and only wraps nested capabilities.
776 if (side === "client") {
777 if (mode === "warn") {
778 try {
779 validator(value, path);
780 } catch (err) {
781 // Validation failed: warn and pass the original value through unwrapped.
782 reportValidationFailure(err);
783 return value;
784 }
785 } else {
786 validator(value, path);
787 }
788 }
789 return wrapResolvedValue(value, validator, path, side);
790}
791
792function wrapResolvedValue(
793 value: unknown,

Callers 3

validateReturnFunction · 0.85
getFunction · 0.85
callValidatedThenFunction · 0.85

Calls 2

reportValidationFailureFunction · 0.85
wrapResolvedValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…