Suite of AT Protocol TypeScript libraries built on web standards
1import { isPlainObject } from "../data/object.ts";
2import {
3 Schema,
4 type ValidationResult,
5 type ValidatorContext,
6} from "../validation.ts";
7
8export type UnknownObjectOutput = Record<string, unknown>;
9
10export class UnknownObjectSchema extends Schema<UnknownObjectOutput> {
11 validateInContext(
12 input: unknown,
13 ctx: ValidatorContext,
14 ): ValidationResult<UnknownObjectOutput> {
15 if (!isPlainObject(input)) {
16 return ctx.issueInvalidType(input, "object");
17 }
18 return ctx.success(input);
19 }
20}