context.d.ts 1.8 KB

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