validate.d.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. export default validate;
  2. export type JSONSchema4 = import('json-schema').JSONSchema4;
  3. export type JSONSchema6 = import('json-schema').JSONSchema6;
  4. export type JSONSchema7 = import('json-schema').JSONSchema7;
  5. export type ErrorObject = import('ajv').ErrorObject;
  6. export type Extend = {
  7. formatMinimum?: number | undefined;
  8. formatMaximum?: number | undefined;
  9. formatExclusiveMinimum?: boolean | undefined;
  10. formatExclusiveMaximum?: boolean | undefined;
  11. };
  12. export type Schema =
  13. | (import('json-schema').JSONSchema4 & Extend)
  14. | (import('json-schema').JSONSchema6 & Extend)
  15. | (import('json-schema').JSONSchema7 & Extend);
  16. export type SchemaUtilErrorObject = import('ajv').ErrorObject & {
  17. children?: import('ajv').ErrorObject[] | undefined;
  18. };
  19. export type PostFormatter = (
  20. formattedError: string,
  21. error: SchemaUtilErrorObject
  22. ) => string;
  23. export type ValidationErrorConfiguration = {
  24. name?: string | undefined;
  25. baseDataPath?: string | undefined;
  26. postFormatter?: PostFormatter | undefined;
  27. };
  28. /**
  29. * @param {Schema} schema
  30. * @param {Array<object> | object} options
  31. * @param {ValidationErrorConfiguration=} configuration
  32. * @returns {void}
  33. */
  34. declare function validate(
  35. schema: Schema,
  36. options: Array<object> | object,
  37. configuration?: ValidationErrorConfiguration | undefined
  38. ): void;
  39. declare namespace validate {
  40. export { ValidationError };
  41. export { ValidationError as ValidateError };
  42. }
  43. import ValidationError from './ValidationError';