@hyperjump/json-schema
Version:
A JSON Schema validator with support for custom keywords, vocabularies, and dialects
69 lines (64 loc) • 2.02 kB
TypeScript
import type { Json } from "@hyperjump/json-pointer";
import type { JsonSchemaType } from "../lib/common.js";
export type JsonSchemaType = JsonSchemaType;
export type JsonSchema = boolean | {
$schema?: "https://json-schema.org/validation";
$id?: string;
$anchor?: string;
$ref?: string;
$dynamicRef?: string;
$dynamicAnchor?: string;
$vocabulary?: Record<string, boolean>;
$comment?: string;
$defs?: Record<string, JsonSchema>;
additionalItems?: JsonSchema;
unevaluatedItems?: JsonSchema;
prefixItems?: JsonSchema[];
items?: JsonSchema;
contains?: JsonSchema;
additionalProperties?: JsonSchema;
unevaluatedProperties?: JsonSchema;
properties?: Record<string, JsonSchema>;
patternProperties?: Record<string, JsonSchema>;
dependentSchemas?: Record<string, JsonSchema>;
propertyNames?: JsonSchema;
if?: JsonSchema;
then?: JsonSchema;
else?: JsonSchema;
allOf?: JsonSchema[];
anyOf?: JsonSchema[];
oneOf?: JsonSchema[];
not?: JsonSchema;
multipleOf?: number;
maximum?: number;
exclusiveMaximum?: number;
minimum?: number;
exclusiveMinimum?: number;
maxLength?: number;
minLength?: number;
pattern?: string;
maxItems?: number;
minItems?: number;
uniqueItems?: boolean;
maxContains?: number;
minContains?: number;
maxProperties?: number;
minProperties?: number;
required?: string[];
dependentRequired?: Record<string, string[]>;
const?: Json;
enum?: Json[];
type?: JsonSchemaType | JsonSchemaType[];
title?: string;
description?: string;
default?: Json;
deprecated?: boolean;
readOnly?: boolean;
writeOnly?: boolean;
examples?: Json[];
format?: "date-time" | "date" | "time" | "duration" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uuid" | "uri-template" | "json-pointer" | "relative-json-pointer" | "regex";
contentMediaType?: string;
contentEncoding?: string;
contentSchema?: JsonSchema;
};
export * from "../lib/index.js";