Type guard to check if a given value is a SerializableSchema, i.e.
both a Standard Schema and a Standard JSON Schema object.
isSerializableSchema<
Input = unknown,
Output = Input
>(schema: SerializableSchema<Input, Output>): schema is SerializableSchema<Input, Output>This checks for both the presence of a Standard Schema V1 interface and the ability to generate a JSON schema.
| Name | Type | Description |
|---|---|---|
schema* | SerializableSchema<Input, Output> | The value to test. |
if (isSerializableSchema(schema)) {
schema["~standard"].validate(data);
const json = schema["~standard"].jsonSchema();
}