ValidationError.d.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. export default ValidationError;
  2. export type JSONSchema6 = import('json-schema').JSONSchema6;
  3. export type JSONSchema7 = import('json-schema').JSONSchema7;
  4. export type Schema =
  5. | (import('json-schema').JSONSchema4 & import('./validate').Extend)
  6. | (import('json-schema').JSONSchema6 & import('./validate').Extend)
  7. | (import('json-schema').JSONSchema7 & import('./validate').Extend);
  8. export type ValidationErrorConfiguration = {
  9. name?: string | undefined;
  10. baseDataPath?: string | undefined;
  11. postFormatter?: import('./validate').PostFormatter | undefined;
  12. };
  13. export type PostFormatter = (
  14. formattedError: string,
  15. error: import('ajv').ErrorObject & {
  16. children?: import('ajv').ErrorObject[] | undefined;
  17. }
  18. ) => string;
  19. export type SchemaUtilErrorObject = import('ajv').ErrorObject & {
  20. children?: import('ajv').ErrorObject[] | undefined;
  21. };
  22. export type SPECIFICITY = number;
  23. declare class ValidationError extends Error {
  24. /**
  25. * @param {Array<SchemaUtilErrorObject>} errors
  26. * @param {Schema} schema
  27. * @param {ValidationErrorConfiguration} configuration
  28. */
  29. constructor(
  30. errors: Array<SchemaUtilErrorObject>,
  31. schema: Schema,
  32. configuration?: ValidationErrorConfiguration
  33. );
  34. /** @type {Array<SchemaUtilErrorObject>} */
  35. errors: Array<SchemaUtilErrorObject>;
  36. /** @type {Schema} */
  37. schema: Schema;
  38. /** @type {string} */
  39. headerName: string;
  40. /** @type {string} */
  41. baseDataPath: string;
  42. /** @type {PostFormatter | null} */
  43. postFormatter: PostFormatter | null;
  44. /**
  45. * @param {string} path
  46. * @returns {Schema}
  47. */
  48. getSchemaPart(path: string): Schema;
  49. /**
  50. * @param {Schema} schema
  51. * @param {boolean} logic
  52. * @param {Array<Object>} prevSchemas
  53. * @returns {string}
  54. */
  55. formatSchema(
  56. schema: Schema,
  57. logic?: boolean,
  58. prevSchemas?: Array<Object>
  59. ): string;
  60. /**
  61. * @param {Schema=} schemaPart
  62. * @param {(boolean | Array<string>)=} additionalPath
  63. * @param {boolean=} needDot
  64. * @param {boolean=} logic
  65. * @returns {string}
  66. */
  67. getSchemaPartText(
  68. schemaPart?: Schema | undefined,
  69. additionalPath?: (boolean | Array<string>) | undefined,
  70. needDot?: boolean | undefined,
  71. logic?: boolean | undefined
  72. ): string;
  73. /**
  74. * @param {Schema=} schemaPart
  75. * @returns {string}
  76. */
  77. getSchemaPartDescription(schemaPart?: Schema | undefined): string;
  78. /**
  79. * @param {SchemaUtilErrorObject} error
  80. * @returns {string}
  81. */
  82. formatValidationError(error: SchemaUtilErrorObject): string;
  83. /**
  84. * @param {Array<SchemaUtilErrorObject>} errors
  85. * @returns {string}
  86. */
  87. formatValidationErrors(errors: Array<SchemaUtilErrorObject>): string;
  88. }