silverbullet/plug-api/syscalls/jsonschema.ts

26 lines
743 B
TypeScript
Raw Normal View History

import { syscall } from "../syscall.ts";
2024-08-07 19:27:25 +08:00
/**
* Validates a JSON object against a JSON schema.
* @param schema the JSON schema to validate against
* @param object the JSON object to validate
* @returns an error message if the object is invalid, or undefined if it is valid
*/
export function validateObject(
schema: any,
object: any,
2024-08-07 19:27:25 +08:00
): Promise<string | undefined> {
return syscall("jsonschema.validateObject", schema, object);
}
2024-08-15 22:39:06 +08:00
/**
* Validates a JSON schema.
* @param schema the JSON schema to validate
* @returns an error message if the schema is invalid, or undefined if it is valid
*/
export function validateSchema(
schema: any,
): Promise<string | undefined> {
return syscall("jsonschema.validateSchema", schema);
}