UNPKG

json-schema-describes-subset

Version:

Tools for static JSON schema analysis, including functions to determine if one schema describes a subset of another or if a schema describes the empty set or to convert a schema to its disjunctive normal form (DNF).

48 lines (47 loc) 1.62 kB
import { AtomicSchemaObject, type LogicalCombinationOfLiterals } from '../atomic-schema/index.js'; import type { ConjunctionSchema, ExtractionPlugin, SimplificationPluginArguments } from '../plugin/index.js'; export declare class PatternAtomicSchema extends AtomicSchemaObject { readonly pattern: string; constructor(pattern: string); negate(): LogicalCombinationOfLiterals; toJSONSchema(): { pattern: string; }; } export declare class MinLengthAtomicSchema extends AtomicSchemaObject { readonly minLength: number; constructor(minLength: number); negate(): LogicalCombinationOfLiterals; toJSONSchema(): { minLength: number; }; } export declare class MaxLengthAtomicSchema extends AtomicSchemaObject { readonly maxLength: number; constructor(maxLength: number); negate(): LogicalCombinationOfLiterals; toJSONSchema(): { maxLength: number; }; } export declare const stringExtraction: ExtractionPlugin; export type StringConjunctionSchema = { minLength?: number; maxLength?: number; allOf?: ({ pattern: string; } | { not: { pattern: string; }; } | { not: { const: string; }; })[]; }; export declare const stringSimplification: { readonly appliesToJSONSchemaType: "string"; readonly mergeableKeywords: ["minLength", "maxLength"]; readonly simplify: ({ schemaDescribesEmptySet, atomicSchemasByConstructor, negatedAtomicSchemasByConstructor, validateConst, }: SimplificationPluginArguments) => ConjunctionSchema<StringConjunctionSchema>; };