WXL
5 天以前 871522ed7e06fd9c62a87c178d7f5c88d7853a20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
export { default as ValidationError } from "./ValidationError";
export type JSONSchema4 = import("json-schema").JSONSchema4;
export type JSONSchema6 = import("json-schema").JSONSchema6;
export type JSONSchema7 = import("json-schema").JSONSchema7;
export type ErrorObject = import("ajv").ErrorObject;
export type ExtendedSchema = {
  /**
   * format minimum
   */
  formatMinimum?: (string | number) | undefined;
  /**
   * format maximum
   */
  formatMaximum?: (string | number) | undefined;
  /**
   * format exclusive minimum
   */
  formatExclusiveMinimum?: (string | boolean) | undefined;
  /**
   * format exclusive maximum
   */
  formatExclusiveMaximum?: (string | boolean) | undefined;
  /**
   * link
   */
  link?: string | undefined;
  /**
   * undefined will be resolved as null
   */
  undefinedAsNull?: boolean | undefined;
};
export type Extend = ExtendedSchema;
export type Schema = (JSONSchema4 | JSONSchema6 | JSONSchema7) & ExtendedSchema;
export type SchemaUtilErrorObject = ErrorObject & {
  children?: Array<ErrorObject>;
};
export type PostFormatter = (
  formattedError: string,
  error: SchemaUtilErrorObject,
) => string;
export type ValidationErrorConfiguration = {
  /**
   * name
   */
  name?: string | undefined;
  /**
   * base data path
   */
  baseDataPath?: string | undefined;
  /**
   * post formatter
   */
  postFormatter?: PostFormatter | undefined;
};
/**
 * @param {Schema} schema schema
 * @param {Array<object> | object} options options
 * @param {ValidationErrorConfiguration=} configuration configuration
 * @returns {void}
 */
export function validate(
  schema: Schema,
  options: Array<object> | object,
  configuration?: ValidationErrorConfiguration | undefined,
): void;
/**
 * @returns {void}
 */
export function enableValidation(): void;
/**
 * @returns {void}
 */
export function disableValidation(): void;
/**
 * @returns {boolean} true when need validate, otherwise false
 */
export function needValidate(): boolean;