import { isBooleanType } from '@jarenjs/core'; import { isRegExpType } from '@jarenjs/core/string'; export declare function isBoolOrObjectClass(obj: any): boolean; /** * getBoolOrObjectClass * extract the data of first parameter if data is boolean or object type otherwise return default * @param {any} obj any data data has to be tested on boolean or object type * @param {boolean | object | undefined} def default return type if not boolean or object type * @returns {boolean | undefined} return value when boolean or object otherwise def */ export declare function getBoolOrObjectClass(obj: any, def?: boolean | object | undefined): boolean | undefined; export declare function getArrayClassMinItems(obj: any, len?: number, def?: undefined): any; export declare function isOfSchemaType(schema: any, type: any): boolean; export declare function hasSchemaRef(schema: any): boolean; export declare function hasSchemaRecursiveRef(schema: any): boolean; export declare function hasSchemaDynamicRef(schema: any): boolean; /** * The keywords that assert something beside a `$ref`: the siblings draft * 2019-09+ applies alongside the reference and draft-07 ignores. * Membership-only (order-insensitive): the shared constraint groups plus * the applicators and extras. One list, read by the schema compiler (does * this `$ref` carry siblings to compile?) and by the reference resolver * (may this hop of a `$ref` chain be flattened away?). */ export declare const REF_SIBLING_KEYWORDS: readonly string[]; /** * Whether a schema carrying a `$ref` also carries a keyword of * {@link REF_SIBLING_KEYWORDS}. * @param {object} schema * @returns {boolean} */ export declare function hasRefSiblings(schema: object): boolean; /** * Whether a sibling keyword of unevaluatedProperties already evaluates every * property of the instance. additionalProperties (boolean or schema) applies * to each property not matched by properties/patternProperties, so once it * has passed no property is left unevaluated. * @param {object} schema - The schema holding the unevaluatedProperties keyword * @returns {boolean} True when the unevaluatedProperties check can never match */ export declare function hasUnevaluatedPropertiesCoverage(schema: object): boolean; /** * Whether a sibling keyword of unevaluatedItems already evaluates every item * of the instance: a uniform items schema (boolean or object) covers all * items beyond any prefixItems, and a tuple-form items with additionalItems * covers the items beyond the tuple. * @param {object} schema - The schema holding the unevaluatedItems keyword * @returns {boolean} True when the unevaluatedItems check can never match */ export declare function hasUnevaluatedItemsCoverage(schema: object): boolean; export declare function createIsSchemaTypeHandler(type: any, isStrict?: boolean): typeof isBooleanType | typeof isRegExpType | undefined; /** * The fallback resolver of the data-reference keywords (`data`, `$data`): * a ref that fails the strict compile keeps the lax keyword semantics, so * it resolves as not-found and the keyword asserts nothing. * @returns {any} the JSON Pointer not-found sentinel */ export declare const resolveNothing: () => any; /** * Build the keyword validators the two data-reference keywords share * verbatim. The `data` keyword (json-everything, absolute + relative * pointers via `compileDataRef`) and the Ajv-style `$data` keyword * (relative pointers only) differ ONLY in which pointer compiler * resolves a ref, so each module passes its own `compileRefResolver` * and gets the same fifteen compilers back. * * Every validator follows one lax contract: a data instance outside the * keyword's type, an unresolvable ref, or a resolved constraint of the * wrong type asserts nothing. * * @param {(ref: string) => (dataRoot: any, dataPath: string) => any} compileRefResolver * @returns {Record ((data: any, dataPath: string, dataRoot: any) => boolean) | undefined>} */ export declare function createDataRefCompilers(compileRefResolver: (ref: string) => (dataRoot: any, dataPath: string) => any): Record ((data: any, dataPath: string, dataRoot: any) => boolean) | undefined>; /** * Records which properties (string keys) and items (numeric indexes) of a * data instance were successfully evaluated during validation, so that * unevaluatedProperties/unevaluatedItems can be checked afterwards. * * Entries are (data reference, key) pairs appended in application order. * Applicators that discard annotations (failed anyOf/oneOf branches, not, * failed if) take a mark() before running and rollback(mark) afterwards. * The numeric key -1 means "all items of this array were evaluated". */ export declare class EvalLog { #private; /** Clears the log; called at the start of each root validation. */ reset(): void; /** @returns {number} The current log position */ mark(): number; /** Discards all entries recorded after the given mark. */ rollback(mark: any): void; /** Records that `key` of instance `data` was evaluated. */ add(data: any, key: any): void; /** @returns {boolean} True when property `key` of `data` was evaluated at or after `from` */ hasKey(data: any, key: any, from: any): boolean; /** @returns {boolean} True when item `index` of `data` was evaluated at or after `from` (-1 entries cover all items) */ hasItem(data: any, index: any, from: any): boolean; } /** * Combine INDEPENDENT keyword validators without short-circuiting. * * `a(...) && b(...)` is the right composition in boolean mode: the answer is * known at the first failure and nothing is gained by continuing. When errors * are recorded it is wrong, because each validator is the only thing that can * report its own fault, so the first failure hides every sibling's. This runs * all of them and ANDs the results — the boolean answer is identical, the * error list is complete. * * Only use it where the validators genuinely are independent. A precondition * (a type guard before a length check) must keep its short-circuit: running * past it is meaningless at best and throws at worst. * @param {Function[]} validators - Independent validators, in report order * @returns {Function} A validator that runs every one of them */ export declare function combineIndependent(validators: Function[]): Function; export declare class ValidationResult { match: boolean; errors: number; static undefThat(): ValidationResult; constructor(match?: boolean, errors?: number); addValid(valid?: boolean): this; addMatch(valid?: boolean): this; addResult(result?: ValidationResult): this; }