index.d.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import type { AddedKeywordDefinition, AnySchemaObject, KeywordErrorCxt, KeywordCxtParams } from "../../types";
  2. import type { SchemaCxt, SchemaObjCxt } from "..";
  3. import { SubschemaArgs } from "./subschema";
  4. import { Code, Name, CodeGen } from "../codegen";
  5. import type { JSONType } from "../rules";
  6. import { ErrorPaths } from "../errors";
  7. export declare function validateFunctionCode(it: SchemaCxt): void;
  8. export declare class KeywordCxt implements KeywordErrorCxt {
  9. readonly gen: CodeGen;
  10. readonly allErrors?: boolean;
  11. readonly keyword: string;
  12. readonly data: Name;
  13. readonly $data?: string | false;
  14. schema: any;
  15. readonly schemaValue: Code | number | boolean;
  16. readonly schemaCode: Code | number | boolean;
  17. readonly schemaType: JSONType[];
  18. readonly parentSchema: AnySchemaObject;
  19. readonly errsCount?: Name;
  20. params: KeywordCxtParams;
  21. readonly it: SchemaObjCxt;
  22. readonly def: AddedKeywordDefinition;
  23. constructor(it: SchemaObjCxt, def: AddedKeywordDefinition, keyword: string);
  24. result(condition: Code, successAction?: () => void, failAction?: () => void): void;
  25. failResult(condition: Code, successAction?: () => void, failAction?: () => void): void;
  26. pass(condition: Code, failAction?: () => void): void;
  27. fail(condition?: Code): void;
  28. fail$data(condition: Code): void;
  29. error(append?: boolean, errorParams?: KeywordCxtParams, errorPaths?: ErrorPaths): void;
  30. private _error;
  31. $dataError(): void;
  32. reset(): void;
  33. ok(cond: Code | boolean): void;
  34. setParams(obj: KeywordCxtParams, assign?: true): void;
  35. block$data(valid: Name, codeBlock: () => void, $dataValid?: Code): void;
  36. check$data(valid?: Name, $dataValid?: Code): void;
  37. invalid$data(): Code;
  38. subschema(appl: SubschemaArgs, valid: Name): SchemaCxt;
  39. mergeEvaluated(schemaCxt: SchemaCxt, toName?: typeof Name): void;
  40. mergeValidEvaluated(schemaCxt: SchemaCxt, valid: Name): boolean | void;
  41. }
  42. export declare function getData($data: string, { dataLevel, dataNames, dataPathArr }: SchemaCxt): Code | number;