stnl
Version:
A simple, opinionated schema library built for performance
46 lines (45 loc) • 1.1 kB
TypeScript
import type { AnySchema } from "./type.ts";
/**
* Define possible output keywords of an stnl schema
*/
export interface V7Schema {
type?: "string" | "number" | "integer" | "array" | "object" | "boolean";
anyOf?: V7Schema[];
$defs?: {
[key: string]: Omit<V7Schema, "$id"> & {
$id: string
}
};
$id?: "";
$ref?: string;
const?: unknown;
items?: V7Schema | false;
prefixItems?: V7Schema[];
properties?: Record<string, V7Schema>;
required?: string[];
minimum?: number;
maximum?: number;
exclusiveMinimum?: number;
exclusiveMaximum?: number;
minLength?: number;
maxLength?: number;
pattern?: string;
title?: string;
description?: string;
default?: unknown;
examples?: unknown[];
deprecated?: true;
readOnly?: true;
writeOnly?: true;
}
export declare const _nullSchema: {
const: null
};
export declare const _toConstSchema: <T>(primitive: T) => {
const: T
};
export declare const _loadLimits: (obj: V7Schema, schema: AnySchema, startIndex: number) => V7Schema;
/**
* Convert an stnl schema to a draft-07 JSON schema
*/
export declare const v7: (schema: AnySchema) => V7Schema;