validate.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 ValidateFunction = import("ajv").ValidateFunction;
  6. export type Extend = {
  7. formatMinimum?: number | undefined;
  8. formatMaximum?: number | undefined;
  9. formatExclusiveMinimum?: boolean | undefined;
  10. formatExclusiveMaximum?: boolean | undefined;
  11. link?: string | undefined;
  12. undefinedAsNull?: boolean | undefined;
  13. };
  14. export type Schema = (JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend;
  15. export type SchemaUtilErrorObject = ErrorObject & {
  16. children?: Array<ErrorObject>;
  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. export function enableValidation(): void;
  39. export function disableValidation(): void;
  40. export function needValidate(): boolean;
  41. import ValidationError from "./ValidationError";
  42. export { ValidationError };