validate.d.ts 1.3 KB

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