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