(value: unknown)
| 434 | } |
| 435 | |
| 436 | export function validateRuntimeResponse(value: unknown): RuntimeValidationResult<RuntimeResponse> { |
| 437 | if (!isRecord(value)) return validationError("$", "Runtime response must be an object") |
| 438 | if (!isRequestId(value.id)) return validationError("$.id", "Runtime response id must be a string or finite number") |
| 439 | if (!("result" in value) && !("error" in value)) return validationError("$", "Runtime response must include result or error") |
| 440 | if ("error" in value) { |
| 441 | if (!isRecord(value.error)) return validationError("$.error", "Runtime response error must be an object") |
| 442 | if (typeof value.error.code !== "string" || value.error.code.length < 1) return validationError("$.error.code", "Runtime response error code must be a non-empty string") |
| 443 | if (typeof value.error.message !== "string" || value.error.message.length < 1) { |
| 444 | return validationError("$.error.message", "Runtime response error message must be a non-empty string") |
| 445 | } |
| 446 | } |
| 447 | return { ok: true, value: value as unknown as RuntimeResponse } |
| 448 | } |
| 449 | |
| 450 | export function validateRuntimeNotification(value: unknown): RuntimeValidationResult<RuntimeNotification> { |
| 451 | if (!isRecord(value)) return validationError("$", "Runtime notification must be an object") |
no test coverage detected