apiful
Version:
Extensible, typed API tooling
27 lines (26 loc) • 710 B
TypeScript
import { ValidationResult, Validator } from "./validator.js";
import { JSONSchema7 } from "json-schema";
//#region src/utils/schema.d.ts
declare const schemaSymbol: unique symbol;
interface Schema<T = unknown> extends Validator<T> {
[schemaSymbol]: true;
/**
* Schema type for inference.
*/
_type: T;
/**
* The JSON Schema for the schema.
*/
readonly jsonSchema: JSONSchema7;
}
/**
* Create a schema using a JSON Schema.
*/
declare function jsonSchema<T = unknown>(jsonSchema: JSONSchema7, {
validate
}?: {
validate?: (value: unknown) => ValidationResult<T>;
}): Schema<T>;
declare function isSchema(value: unknown): value is Schema;
//#endregion
export { Schema, isSchema, jsonSchema };