@rjsf/validator-ajv8 5.7.2 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.development.js +10 -1
- package/dist/index.cjs.development.js.map +1 -1
- package/dist/index.cjs.production.min.js +1 -1
- package/dist/index.cjs.production.min.js.map +1 -1
- package/dist/validator-ajv8.esm.js +11 -2
- package/dist/validator-ajv8.esm.js.map +1 -1
- package/dist/validator-ajv8.umd.development.js +10 -1
- package/dist/validator-ajv8.umd.development.js.map +1 -1
- package/dist/validator-ajv8.umd.production.min.js +1 -1
- package/dist/validator-ajv8.umd.production.min.js.map +1 -1
- package/package.json +12 -11
|
@@ -283,6 +283,11 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
|
|
|
283
283
|
* @private
|
|
284
284
|
*/
|
|
285
285
|
this.rootSchema = void 0;
|
|
286
|
+
/** The root schema resolved top level refs
|
|
287
|
+
*
|
|
288
|
+
* @private
|
|
289
|
+
*/
|
|
290
|
+
this.resolvedRootSchema = void 0;
|
|
286
291
|
/** The `ValidatorFunctions` map used to construct this validator
|
|
287
292
|
*
|
|
288
293
|
* @private
|
|
@@ -302,6 +307,7 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
|
|
|
302
307
|
this.validateFns = validateFns;
|
|
303
308
|
this.localizer = localizer;
|
|
304
309
|
this.mainValidator = this.getValidator(rootSchema);
|
|
310
|
+
this.resolvedRootSchema = utils.retrieveSchema(this, rootSchema, rootSchema);
|
|
305
311
|
}
|
|
306
312
|
/** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator
|
|
307
313
|
* functions.
|
|
@@ -339,7 +345,7 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
|
|
|
339
345
|
* @throws - Error when the schema provided does not match the base schema of the precompiled validator
|
|
340
346
|
*/;
|
|
341
347
|
_proto.rawValidation = function rawValidation(schema, formData) {
|
|
342
|
-
if (!isEqual__default["default"](schema, this.
|
|
348
|
+
if (!isEqual__default["default"](schema, this.resolvedRootSchema)) {
|
|
343
349
|
throw new Error('The schema associated with the precompiled schema differs from the schema provided for validation');
|
|
344
350
|
}
|
|
345
351
|
this.mainValidator(formData);
|
|
@@ -382,6 +388,9 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
|
|
|
382
388
|
if (!isEqual__default["default"](rootSchema, this.rootSchema)) {
|
|
383
389
|
throw new Error('The schema associated with the precompiled validator differs from the rootSchema provided for validation');
|
|
384
390
|
}
|
|
391
|
+
if (get__default["default"](schema, utils.ID_KEY) === utils.JUNK_OPTION_ID) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
385
394
|
var validator = this.getValidator(schema);
|
|
386
395
|
return validator(formData);
|
|
387
396
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.development.js","sources":["../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/precompiledValidator.ts","../src/createPrecompiledValidator.ts","../src/index.ts"],"sourcesContent":["import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n","import customizeValidator from './customizeValidator';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n"],"names":["transformRJSFValidationErrors","errors","uiSchema","map","e","instancePath","keyword","params","schemaPath","parentSchema","rest","_objectWithoutPropertiesLoose","_excluded","_rest$message","message","property","replace","stack","trim","missingProperty","currentProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","invalidSchemaError","validationError","concat","errorSchema","toErrorSchema","_extends","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","ajv","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","createAjvInstance","_proto","prototype","toErrorList","fieldPath","rawValidation","compilationError","undefined","compiledValidator","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","result","console","warn","removeSchema","customizeValidator","AJV8PrecompiledValidator","validateFns","mainVal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;;AAUG;AACqB,SAAAQ,0BAA0BA,CAIhDP,WAA+B,EAAEb,UAAa,EAAEtB,SAAqB,EAAA;EACrE,OAAO,IAAIkC,wBAAwB,CAAUC,WAAW,EAAEb,UAAU,EAAEtB,SAAS,CAAC,CAAA;AAClF;;AChBA,YAAeiC,aAAAA,kBAAkB,EAAE;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.development.js","sources":["../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/precompiledValidator.ts","../src/createPrecompiledValidator.ts","../src/index.ts"],"sourcesContent":["import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n JUNK_OPTION_ID,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n retrieveSchema,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The root schema resolved top level refs\n *\n * @private\n */\n readonly resolvedRootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n this.resolvedRootSchema = retrieveSchema(this, rootSchema, rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.resolvedRootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n if (get(schema, ID_KEY) === JUNK_OPTION_ID) {\n return false;\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n","import customizeValidator from './customizeValidator';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n"],"names":["transformRJSFValidationErrors","errors","uiSchema","map","e","instancePath","keyword","params","schemaPath","parentSchema","rest","_objectWithoutPropertiesLoose","_excluded","_rest$message","message","property","replace","stack","trim","missingProperty","currentProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","invalidSchemaError","validationError","concat","errorSchema","toErrorSchema","_extends","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","ajv","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","createAjvInstance","_proto","prototype","toErrorList","fieldPath","rawValidation","compilationError","undefined","compiledValidator","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","result","console","warn","removeSchema","customizeValidator","AJV8PrecompiledValidator","validateFns","resolvedRootSchema","mainValidator","getValidator","retrieveSchema","key","hashForSchema","Error","isEqual","JUNK_OPTION_ID","createPrecompiledValidator"],"mappings":";;;;;;;;;;;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AA;AACb,KAAA;AACD,IAAA,IAAMnE,SAAS,GAAG,IAAI,CAAC6D,YAAY,CAAC1D,MAAM,CAAC,CAAA;IAC3C,OAAOH,SAAS,CAACE,QAAQ,CAAC,CAAA;GAC3B,CAAA;AAAA,EAAA,OAAAuD,wBAAA,CAAA;AAAA,CAAA,EAAA;;ACvKH;;;;;;;;;;AAUG;AACqB,SAAAW,0BAA0BA,CAIhDV,WAA+B,EAAEb,UAAa,EAAEtB,SAAqB,EAAA;EACrE,OAAO,IAAIkC,wBAAwB,CAAUC,WAAW,EAAEb,UAAU,EAAEtB,SAAS,CAAC,CAAA;AAClF;;AChBA,YAAeiC,aAAAA,kBAAkB,EAAE;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@rjsf/utils"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@rjsf/utils"),e=require("./createAjvInstance-0cd8cfba.js"),t=require("lodash/get"),a=require("lodash/isEqual");function i(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}require("ajv"),require("ajv-formats"),require("lodash/isObject");var o=i(t),s=i(a),n=["instancePath","keyword","params","schemaPath","parentSchema"];function c(t,a,i,s,c,l,h){var d=a.validationError,u=function(t,a){return void 0===t&&(t=[]),t.map((function(t){var i=t.instancePath,s=t.keyword,c=t.params,l=t.schemaPath,h=t.parentSchema,d=e._objectWithoutPropertiesLoose(t,n).message,u=void 0===d?"":d,v=i.replace(/\//g,"."),m=(v+" "+u).trim();if("missingProperty"in c){var f=c.missingProperty,p=r.getUiOptions(o.default(a,""+(v=v?v+"."+c.missingProperty:c.missingProperty).replace(/^\./,""))).title;if(p)u=u.replace(f,p);else{var E=o.default(h,[r.PROPERTIES_KEY,f,"title"]);E&&(u=u.replace(f,E))}m=u}else{var S=r.getUiOptions(o.default(a,""+v.replace(/^\./,""))).title;if(S)m=("'"+S+"' "+u).trim();else{var g=null==h?void 0:h.title;g&&(m=("'"+g+"' "+u).trim())}}return{name:s,property:v,message:u,params:c,stack:m,schemaPath:l}}))}(a.errors,h);d&&(u=[].concat(u,[{stack:d.message}])),"function"==typeof l&&(u=l(u,h));var v=r.toErrorSchema(u);if(d&&(v=e._extends({},v,{$schema:{__errors:[d.message]}})),"function"!=typeof c)return{errors:u,errorSchema:v};var m=r.getDefaultFormState(t,s,i,s,!0),f=c(m,r.createErrorHandler(m),h),p=r.unwrapErrorHandler(f);return r.validationDataMerge({errors:u,errorSchema:v},p)}var l=function(){function t(r,t){this.ajv=void 0,this.localizer=void 0,this.ajv=e.createAjvInstance(r.additionalMetaSchemas,r.customFormats,r.ajvOptionsOverrides,r.ajvFormatOptions,r.AjvClass),this.localizer=t}var a=t.prototype;return a.toErrorList=function(e,t){return void 0===t&&(t=[]),r.toErrorList(e,t)},a.rawValidation=function(e,t){var a,i,o=void 0;e[r.ID_KEY]&&(a=this.ajv.getSchema(e[r.ID_KEY]));try{void 0===a&&(a=this.ajv.compile(e)),a(t)}catch(r){o=r}return a&&("function"==typeof this.localizer&&this.localizer(a.errors),i=a.errors||void 0,a.errors=null),{errors:i,validationError:o}},a.validateFormData=function(r,e,t,a,i){return c(this,this.rawValidation(e,r),r,e,t,a,i)},a.isValid=function(e,t,a){var i,o=null!=(i=a[r.ID_KEY])?i:r.ROOT_SCHEMA_PREFIX;try{void 0===this.ajv.getSchema(o)&&this.ajv.addSchema(a,o);var s,n=r.withIdRefPrefix(e);return n[r.ID_KEY]&&(s=this.ajv.getSchema(n[r.ID_KEY])),void 0===s&&(s=this.ajv.compile(n)),s(t)}catch(r){return console.warn("Error encountered compiling schema:",r),!1}finally{this.ajv.removeSchema(o)}},t}();function h(r,e){return void 0===r&&(r={}),new l(r,e)}var d=function(){function e(e,t,a){this.rootSchema=void 0,this.resolvedRootSchema=void 0,this.validateFns=void 0,this.mainValidator=void 0,this.localizer=void 0,this.rootSchema=t,this.validateFns=e,this.localizer=a,this.mainValidator=this.getValidator(t),this.resolvedRootSchema=r.retrieveSchema(this,t,t)}var t=e.prototype;return t.getValidator=function(e){var t=o.default(e,r.ID_KEY)||r.hashForSchema(e),a=this.validateFns[t];if(!a)throw new Error('No precompiled validator function was found for the given schema for "'+t+'"');return a},t.toErrorList=function(e,t){return void 0===t&&(t=[]),r.toErrorList(e,t)},t.rawValidation=function(r,e){if(!s.default(r,this.resolvedRootSchema))throw new Error("The schema associated with the precompiled schema differs from the schema provided for validation");this.mainValidator(e),"function"==typeof this.localizer&&this.localizer(this.mainValidator.errors);var t=this.mainValidator.errors||void 0;return this.mainValidator.errors=null,{errors:t}},t.validateFormData=function(r,e,t,a,i){return c(this,this.rawValidation(e,r),r,e,t,a,i)},t.isValid=function(e,t,a){if(!s.default(a,this.rootSchema))throw new Error("The schema associated with the precompiled validator differs from the rootSchema provided for validation");return o.default(e,r.ID_KEY)!==r.JUNK_OPTION_ID&&this.getValidator(e)(t)},e}(),u=h();exports.createPrecompiledValidator=function(r,e,t){return new d(r,e,t)},exports.customizeValidator=h,exports.default=u;
|
|
2
2
|
//# sourceMappingURL=index.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.production.min.js","sources":["../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/precompiledValidator.ts","../src/index.ts","../src/createPrecompiledValidator.ts"],"sourcesContent":["import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import customizeValidator from './customizeValidator';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n"],"names":["processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","uiSchema","invalidSchemaError","validationError","errors","map","e","instancePath","keyword","params","schemaPath","parentSchema","_rest$message","_objectWithoutPropertiesLoose","_excluded","message","property","replace","stack","trim","currentProperty","missingProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","transformRJSFValidationErrors","concat","errorSchema","toErrorSchema","_extends","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","this","ajv","createAjvInstance","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","_proto","prototype","toErrorList","fieldPath","rawValidation","compiledValidator","compilationError","undefined","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","console","warn","removeSchema","customizeValidator","AJV8PrecompiledValidator","validateFns","mainValidator","getValidator","key","hashForSchema","Error","isEqual"],"mappings":"+ZA8Fc,SAAUA,EAKtBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAEA,IAAyBC,EAAuBN,EAAxCO,gBACJC,WA5EJA,EAA4BH,GAC5B,YADwB,IAAxBG,IAAAA,EAAwB,IACjBA,EAAOC,KAAI,SAACC,GACjB,IAAQC,EAAqED,EAArEC,aAAcC,EAAuDF,EAAvDE,QAASC,EAA8CH,EAA9CG,OAAQC,EAAsCJ,EAAtCI,WAAYC,EAA0BL,EAA1BK,aACnDC,EADwEC,EAAAA,8BAAKP,EAACQ,GACxEC,QAAAA,OAAU,IAAHH,EAAG,GAAEA,EACdI,EAAWT,EAAaU,QAAQ,MAAO,KACvCC,GAAWF,MAAYD,GAAUI,OAErC,GAAI,oBAAqBV,EAAQ,CAE/B,IAAMW,EAA0BX,EAAOY,gBACjCC,EAAgBC,EAAAA,aAAaC,EAAG,QAACvB,EAAae,IAFpDA,EAAWA,EAAcA,EAAQ,IAAIP,EAAOY,gBAAoBZ,EAAOY,iBAEVJ,QAAQ,MAAO,MAAQQ,MAEpF,GAAIH,EACFP,EAAUA,EAAQE,QAAQG,EAAiBE,OACtC,CACL,IAAMI,EAAoBF,EAAAA,QAAIb,EAAc,CAACgB,EAAAA,eAAgBP,EAAiB,UAE1EM,IACFX,EAAUA,EAAQE,QAAQG,EAAiBM,GAE9C,CAEDR,EAAQH,CACT,KAAM,CACL,IAAMO,EAAgBC,EAAAA,aAAsBC,EAAG,QAACvB,EAAae,GAAAA,EAASC,QAAQ,MAAO,MAAQQ,MAE7F,GAAIH,EACFJ,OAAYI,EAAa,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AAA,uCCUS,SAItBE,EAAiCZ,EAAevB,GAChD,OAAO,IAAIkC,EAAkCC,EAAaZ,EAAYvB,EACxE"}
|
|
1
|
+
{"version":3,"file":"index.cjs.production.min.js","sources":["../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/precompiledValidator.ts","../src/index.ts","../src/createPrecompiledValidator.ts"],"sourcesContent":["import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n JUNK_OPTION_ID,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n retrieveSchema,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The root schema resolved top level refs\n *\n * @private\n */\n readonly resolvedRootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n this.resolvedRootSchema = retrieveSchema(this, rootSchema, rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.resolvedRootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n if (get(schema, ID_KEY) === JUNK_OPTION_ID) {\n return false;\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import customizeValidator from './customizeValidator';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n"],"names":["processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","uiSchema","invalidSchemaError","validationError","errors","map","e","instancePath","keyword","params","schemaPath","parentSchema","_rest$message","_objectWithoutPropertiesLoose","_excluded","message","property","replace","stack","trim","currentProperty","missingProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","transformRJSFValidationErrors","concat","errorSchema","toErrorSchema","_extends","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","this","ajv","createAjvInstance","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","_proto","prototype","toErrorList","fieldPath","rawValidation","compiledValidator","compilationError","undefined","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","console","warn","removeSchema","customizeValidator","AJV8PrecompiledValidator","validateFns","resolvedRootSchema","mainValidator","getValidator","retrieveSchema","key","hashForSchema","Error","isEqual","JUNK_OPTION_ID"],"mappings":"+ZA8Fc,SAAUA,EAKtBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAEA,IAAyBC,EAAuBN,EAAxCO,gBACJC,WA5EJA,EAA4BH,GAC5B,YADwB,IAAxBG,IAAAA,EAAwB,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E,EAAMA,SAAKwB,EAAAA,cAAcxF,GAC3CH,EAAYmD,KAAKkC,YAAYK,GACnC,IAAK1F,EACH,MAAM,IAAI4F,MAA+EF,yEAAAA,OAE3F,OAAO1F,CACT,EAEA2D,EAOAE,YAAA,SAAYzB,EAA8B0B,GACxC,YADwC,IAAAA,IAAAA,EAAsB,IACvDD,EAAWA,YAACzB,EAAa0B,EAClC,EAEAH,EAOAI,cAAA,SAA4B5D,EAAWD,GACrC,IAAK2F,EAAAA,QAAQ1F,EAAQgD,KAAKmC,oBACxB,MAAM,IAAIM,MACR,qGAGJzC,KAAKoC,cAAcrF,GAEW,mBAAnBiD,KAAKD,WACdC,KAAKD,UAAUC,KAAKoC,cAAc9E,QAEpC,IAAMA,EAAS0C,KAAKoC,cAAc9E,aAAUyD,EAK5C,OAFAf,KAAKoC,cAAc9E,OAAS,KAErB,CAAEA,OAAQA,EACnB,EAEAkD,EAWAY,iBAAA,SACErE,EACAC,EACAC,EACAC,EACAC,GAGA,OAAOP,EAA2BoD,KADhBA,KAAKY,cAA2B5D,EAAQD,GACPA,EAAUC,EAAQC,EAAgBC,EAAiBC,EACxG,EAEAqD,EAUAa,QAAA,SAAQrE,EAAWD,EAAyBuE,GAC1C,IAAKoB,EAAAA,QAAQpB,EAAYtB,KAAKsB,YAC5B,MAAM,IAAImB,MACR,4GAGJ,OAAI/D,UAAI1B,EAAQgE,EAAMA,UAAM2B,EAAAA,gBAGV3C,KAAKqC,aAAarF,EAC7BH,CAAUE,IAClBkF,CAAA,CAlJ0C,GCpB9BD,EAAAA,uCCUS,SAItBE,EAAiCZ,EAAevB,GAChD,OAAO,IAAIkC,EAAkCC,EAAaZ,EAAYvB,EACxE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG, toErrorSchema, getDefaultFormState, createErrorHandler, unwrapErrorHandler, validationDataMerge, getUiOptions, PROPERTIES_KEY, toErrorList, ID_KEY, withIdRefPrefix, ROOT_SCHEMA_PREFIX, hashForSchema } from '@rjsf/utils';
|
|
1
|
+
import { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG, toErrorSchema, getDefaultFormState, createErrorHandler, unwrapErrorHandler, validationDataMerge, getUiOptions, PROPERTIES_KEY, toErrorList, ID_KEY, withIdRefPrefix, ROOT_SCHEMA_PREFIX, retrieveSchema, hashForSchema, JUNK_OPTION_ID } from '@rjsf/utils';
|
|
2
2
|
import Ajv from 'ajv';
|
|
3
3
|
import addFormats from 'ajv-formats';
|
|
4
4
|
import isObject from 'lodash-es/isObject';
|
|
@@ -355,6 +355,11 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
|
|
|
355
355
|
* @private
|
|
356
356
|
*/
|
|
357
357
|
this.rootSchema = void 0;
|
|
358
|
+
/** The root schema resolved top level refs
|
|
359
|
+
*
|
|
360
|
+
* @private
|
|
361
|
+
*/
|
|
362
|
+
this.resolvedRootSchema = void 0;
|
|
358
363
|
/** The `ValidatorFunctions` map used to construct this validator
|
|
359
364
|
*
|
|
360
365
|
* @private
|
|
@@ -374,6 +379,7 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
|
|
|
374
379
|
this.validateFns = validateFns;
|
|
375
380
|
this.localizer = localizer;
|
|
376
381
|
this.mainValidator = this.getValidator(rootSchema);
|
|
382
|
+
this.resolvedRootSchema = retrieveSchema(this, rootSchema, rootSchema);
|
|
377
383
|
}
|
|
378
384
|
/** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator
|
|
379
385
|
* functions.
|
|
@@ -411,7 +417,7 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
|
|
|
411
417
|
* @throws - Error when the schema provided does not match the base schema of the precompiled validator
|
|
412
418
|
*/;
|
|
413
419
|
_proto.rawValidation = function rawValidation(schema, formData) {
|
|
414
|
-
if (!isEqual(schema, this.
|
|
420
|
+
if (!isEqual(schema, this.resolvedRootSchema)) {
|
|
415
421
|
throw new Error('The schema associated with the precompiled schema differs from the schema provided for validation');
|
|
416
422
|
}
|
|
417
423
|
this.mainValidator(formData);
|
|
@@ -454,6 +460,9 @@ var AJV8PrecompiledValidator = /*#__PURE__*/function () {
|
|
|
454
460
|
if (!isEqual(rootSchema, this.rootSchema)) {
|
|
455
461
|
throw new Error('The schema associated with the precompiled validator differs from the rootSchema provided for validation');
|
|
456
462
|
}
|
|
463
|
+
if (get(schema, ID_KEY) === JUNK_OPTION_ID) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
457
466
|
var validator = this.getValidator(schema);
|
|
458
467
|
return validator(formData);
|
|
459
468
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator-ajv8.esm.js","sources":["../src/createAjvInstance.ts","../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/precompiledValidator.ts","../src/createPrecompiledValidator.ts","../src/index.ts"],"sourcesContent":["import Ajv, { Options } from 'ajv';\nimport addFormats, { FormatsPluginOptions } from 'ajv-formats';\nimport isObject from 'lodash/isObject';\n\nimport { CustomValidatorOptionsType } from './types';\nimport { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG } from '@rjsf/utils';\n\nexport const AJV_CONFIG: Options = {\n allErrors: true,\n multipleOfPrecision: 8,\n strict: false,\n verbose: true,\n} as const;\nexport const COLOR_FORMAT_REGEX =\n /^(#?([0-9A-Fa-f]{3}){1,2}\\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\\(\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*\\))|(rgb\\(\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*\\)))$/;\nexport const DATA_URL_FORMAT_REGEX = /^data:([a-z]+\\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;\n\n/** Creates an Ajv version 8 implementation object with standard support for the 'color` and `data-url` custom formats.\n * If `additionalMetaSchemas` are provided then the Ajv instance is modified to add each of the meta schemas in the\n * list. If `customFormats` are provided then those additional formats are added to the list of supported formats. If\n * `ajvOptionsOverrides` are provided then they are spread on top of the default `AJV_CONFIG` options when constructing\n * the `Ajv` instance. With Ajv v8, the JSON Schema formats are not provided by default, but can be plugged in. By\n * default, all formats from the `ajv-formats` library are added. To disable this capability, set the `ajvFormatOptions`\n * parameter to `false`. Additionally, you can configure the `ajv-formats` by providing a custom set of\n * [format options](https://github.com/ajv-validator/ajv-formats) to the `ajvFormatOptions` parameter.\n *\n * @param [additionalMetaSchemas] - The list of additional meta schemas that the validator can access\n * @param [customFormats] - The set of additional custom formats that the validator will support\n * @param [ajvOptionsOverrides={}] - The set of validator config override options\n * @param [ajvFormatOptions] - The `ajv-format` options to use when adding formats to `ajv`; pass `false` to disable it\n * @param [AjvClass] - The `Ajv` class to use when creating the validator instance\n */\nexport default function createAjvInstance(\n additionalMetaSchemas?: CustomValidatorOptionsType['additionalMetaSchemas'],\n customFormats?: CustomValidatorOptionsType['customFormats'],\n ajvOptionsOverrides: CustomValidatorOptionsType['ajvOptionsOverrides'] = {},\n ajvFormatOptions?: FormatsPluginOptions | false,\n AjvClass: typeof Ajv = Ajv\n) {\n const ajv = new AjvClass({ ...AJV_CONFIG, ...ajvOptionsOverrides });\n if (ajvFormatOptions) {\n addFormats(ajv, ajvFormatOptions);\n } else if (ajvFormatOptions !== false) {\n addFormats(ajv);\n }\n\n // add custom formats\n ajv.addFormat('data-url', DATA_URL_FORMAT_REGEX);\n ajv.addFormat('color', COLOR_FORMAT_REGEX);\n\n // Add RJSF-specific additional properties keywords so Ajv doesn't report errors if strict is enabled.\n ajv.addKeyword(ADDITIONAL_PROPERTY_FLAG);\n ajv.addKeyword(RJSF_ADDITONAL_PROPERTIES_FLAG);\n\n // add more schemas to validate against\n if (Array.isArray(additionalMetaSchemas)) {\n ajv.addMetaSchema(additionalMetaSchemas);\n }\n\n // add more custom formats to validate against\n if (isObject(customFormats)) {\n Object.keys(customFormats).forEach((formatName) => {\n ajv.addFormat(formatName, customFormats[formatName]);\n });\n }\n\n return ajv;\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n","import customizeValidator from './customizeValidator';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n"],"names":["AJV_CONFIG","allErrors","multipleOfPrecision","strict","verbose","COLOR_FORMAT_REGEX","DATA_URL_FORMAT_REGEX","createAjvInstance","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","ajv","_extends","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName","transformRJSFValidationErrors","errors","uiSchema","map","e","instancePath","keyword","params","schemaPath","parentSchema","rest","_objectWithoutPropertiesLoose","_excluded","_rest$message","message","property","replace","stack","trim","missingProperty","currentProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","invalidSchemaError","validationError","concat","errorSchema","toErrorSchema","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","_proto","prototype","toErrorList","fieldPath","rawValidation","compilationError","undefined","compiledValidator","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","result","console","warn","removeSchema","customizeValidator","AJV8PrecompiledValidator","validateFns","mainValidator","getValidator","key","hashForSchema","Error","isEqual","createPrecompiledValidator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,IAAMA,UAAU,GAAY;AACjCC,EAAAA,SAAS,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AACD,IAAA,IAAMvD,SAAS,GAAG,IAAI,CAACoD,YAAY,CAACjD,MAAM,CAAC,CAAA;IAC3C,OAAOH,SAAS,CAACE,QAAQ,CAAC,CAAA;GAC3B,CAAA;AAAA,EAAA,OAAA+C,wBAAA,CAAA;AAAA,CAAA,EAAA;;AC3JH;;;;;;;;;;AAUG;AACqB,SAAAQ,0BAA0BA,CAIhDP,WAA+B,EAAEb,UAAa,EAAEf,SAAqB,EAAA;EACrE,OAAO,IAAI2B,wBAAwB,CAAUC,WAAW,EAAEb,UAAU,EAAEf,SAAS,CAAC,CAAA;AAClF;;AChBA,YAAe0B,aAAAA,kBAAkB,EAAE;;;;"}
|
|
1
|
+
{"version":3,"file":"validator-ajv8.esm.js","sources":["../src/createAjvInstance.ts","../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/precompiledValidator.ts","../src/createPrecompiledValidator.ts","../src/index.ts"],"sourcesContent":["import Ajv, { Options } from 'ajv';\nimport addFormats, { FormatsPluginOptions } from 'ajv-formats';\nimport isObject from 'lodash/isObject';\n\nimport { CustomValidatorOptionsType } from './types';\nimport { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG } from '@rjsf/utils';\n\nexport const AJV_CONFIG: Options = {\n allErrors: true,\n multipleOfPrecision: 8,\n strict: false,\n verbose: true,\n} as const;\nexport const COLOR_FORMAT_REGEX =\n /^(#?([0-9A-Fa-f]{3}){1,2}\\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\\(\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*\\))|(rgb\\(\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*\\)))$/;\nexport const DATA_URL_FORMAT_REGEX = /^data:([a-z]+\\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;\n\n/** Creates an Ajv version 8 implementation object with standard support for the 'color` and `data-url` custom formats.\n * If `additionalMetaSchemas` are provided then the Ajv instance is modified to add each of the meta schemas in the\n * list. If `customFormats` are provided then those additional formats are added to the list of supported formats. If\n * `ajvOptionsOverrides` are provided then they are spread on top of the default `AJV_CONFIG` options when constructing\n * the `Ajv` instance. With Ajv v8, the JSON Schema formats are not provided by default, but can be plugged in. By\n * default, all formats from the `ajv-formats` library are added. To disable this capability, set the `ajvFormatOptions`\n * parameter to `false`. Additionally, you can configure the `ajv-formats` by providing a custom set of\n * [format options](https://github.com/ajv-validator/ajv-formats) to the `ajvFormatOptions` parameter.\n *\n * @param [additionalMetaSchemas] - The list of additional meta schemas that the validator can access\n * @param [customFormats] - The set of additional custom formats that the validator will support\n * @param [ajvOptionsOverrides={}] - The set of validator config override options\n * @param [ajvFormatOptions] - The `ajv-format` options to use when adding formats to `ajv`; pass `false` to disable it\n * @param [AjvClass] - The `Ajv` class to use when creating the validator instance\n */\nexport default function createAjvInstance(\n additionalMetaSchemas?: CustomValidatorOptionsType['additionalMetaSchemas'],\n customFormats?: CustomValidatorOptionsType['customFormats'],\n ajvOptionsOverrides: CustomValidatorOptionsType['ajvOptionsOverrides'] = {},\n ajvFormatOptions?: FormatsPluginOptions | false,\n AjvClass: typeof Ajv = Ajv\n) {\n const ajv = new AjvClass({ ...AJV_CONFIG, ...ajvOptionsOverrides });\n if (ajvFormatOptions) {\n addFormats(ajv, ajvFormatOptions);\n } else if (ajvFormatOptions !== false) {\n addFormats(ajv);\n }\n\n // add custom formats\n ajv.addFormat('data-url', DATA_URL_FORMAT_REGEX);\n ajv.addFormat('color', COLOR_FORMAT_REGEX);\n\n // Add RJSF-specific additional properties keywords so Ajv doesn't report errors if strict is enabled.\n ajv.addKeyword(ADDITIONAL_PROPERTY_FLAG);\n ajv.addKeyword(RJSF_ADDITONAL_PROPERTIES_FLAG);\n\n // add more schemas to validate against\n if (Array.isArray(additionalMetaSchemas)) {\n ajv.addMetaSchema(additionalMetaSchemas);\n }\n\n // add more custom formats to validate against\n if (isObject(customFormats)) {\n Object.keys(customFormats).forEach((formatName) => {\n ajv.addFormat(formatName, customFormats[formatName]);\n });\n }\n\n return ajv;\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n JUNK_OPTION_ID,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n retrieveSchema,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The root schema resolved top level refs\n *\n * @private\n */\n readonly resolvedRootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n this.resolvedRootSchema = retrieveSchema(this, rootSchema, rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.resolvedRootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n if (get(schema, ID_KEY) === JUNK_OPTION_ID) {\n return false;\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n","import customizeValidator from './customizeValidator';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n"],"names":["AJV_CONFIG","allErrors","multipleOfPrecision","strict","verbose","COLOR_FORMAT_REGEX","DATA_URL_FORMAT_REGEX","createAjvInstance","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","ajv","_extends","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName","transformRJSFValidationErrors","errors","uiSchema","map","e","instancePath","keyword","params","schemaPath","parentSchema","rest","_objectWithoutPropertiesLoose","_excluded","_rest$message","message","property","replace","stack","trim","missingProperty","currentProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","invalidSchemaError","validationError","concat","errorSchema","toErrorSchema","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","_proto","prototype","toErrorList","fieldPath","rawValidation","compilationError","undefined","compiledValidator","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","result","console","warn","removeSchema","customizeValidator","AJV8PrecompiledValidator","validateFns","resolvedRootSchema","mainValidator","getValidator","retrieveSchema","key","hashForSchema","Error","isEqual","JUNK_OPTION_ID","createPrecompiledValidator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,IAAMA,UAAU,GAAY;AACjCC,EAAAA,SAAS,EAAE,IAAI;AACfC,EAAAA,mBAAmB,EAAE,CAAC;AACtBC,EAAAA,MAAM,EAAE,KAAK;AACbC,EAAAA,OAAO,EAAE,IAAA;CACD,CAAA;AACH,IAAMC,kBAAkB,GAC7B,4YAA4Y,CAAA;AACvY,IAAMC,qBAAqB,GAAG,2DAA2D,CAAA;AAEhG;;;;;;;;;;;;;;AAcG;AACqB,SAAAC,iBAAiBA,CACvCC,qBAA2E,EAC3EC,aAA2D,EAC3DC,qBACAC,gBAA+C,EAC/CC,UAA0B;AAAA,EAAA,IAF1BF;IAAAA,sBAAyE,EAAE,CAAA;AAAA,GAAA;AAAA,EAAA,IAE3EE;AAAAA,IAAAA,WAAuBC,GAAG,CAAA;AAAA,GAAA;EAE1B,IAAMC,GAAG,GAAG,IAAIF,QAAQ,CAAAG,QAAA,CAAA,EAAA,EAAMf,UAAU,EAAKU,mBAAmB,CAAE,CAAC,CAAA;AACnE,EAAA,IAAIC,gBAAgB,EAAE;AACpBK,IAAAA,UAAU,CAACF,GAAG,EAAEH,gBAAgB,CAAC,CAAA;AAClC,GAAA,MAAM,IAAIA,gBAAgB,KAAK,KAAK,EAAE;IACrCK,UAAU,CAACF,GAAG,CAAC,CAAA;AAChB,GAAA;AAED;AACAA,EAAAA,GAAG,CAACG,SAAS,CAAC,UAAU,EAAEX,qBAAqB,CAAC,CAAA;AAChDQ,EAAAA,GAAG,CAACG,SAAS,CAAC,OAAO,EAAEZ,kBAAkB,CAAC,CAAA;AAE1C;AACAS,EAAAA,GAAG,CAACI,UAAU,CAACC,wBAAwB,CAAC,CAAA;AACxCL,EAAAA,GAAG,CAACI,UAAU,CAACE,8BAA8B,CAA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S,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,cAAc,EAAEC,eAAe,EAAEhC,QAAQ,CAAC,CAAA;AACjH,GAAA;AAEA;;;;;;;;;AASG,MATH;EAAAkD,MAAA,CAUAa,OAAO,GAAP,SAAAA,OAAAA,CAAQjC,MAAS,EAAED,QAAuB,EAAEmC,UAAa,EAAA;IACvD,IAAI,CAACqB,OAAO,CAACrB,UAAU,EAAE,IAAI,CAACA,UAAU,CAAC,EAAE;AACzC,MAAA,MAAM,IAAIoB,KAAK,CACb,0GAA0G,CAC3G,CAAA;AACF,KAAA;IACD,IAAI/D,GAAG,CAACS,MAAM,EAAE4B,MAAM,CAAC,KAAK4B,cAAc,EAAE;AAC1C,MAAA,OAAO,KAAK,CAAA;AACb,KAAA;AACD,IAAA,IAAM3D,SAAS,GAAG,IAAI,CAACqD,YAAY,CAAClD,MAAM,CAAC,CAAA;IAC3C,OAAOH,SAAS,CAACE,QAAQ,CAAC,CAAA;GAC3B,CAAA;AAAA,EAAA,OAAA+C,wBAAA,CAAA;AAAA,CAAA,EAAA;;ACvKH;;;;;;;;;;AAUG;AACqB,SAAAW,0BAA0BA,CAIhDV,WAA+B,EAAEb,UAAa,EAAEf,SAAqB,EAAA;EACrE,OAAO,IAAI2B,wBAAwB,CAAUC,WAAW,EAAEb,UAAU,EAAEf,SAAS,CAAC,CAAA;AAClF;;AChBA,YAAe0B,aAAAA,kBAAkB,EAAE;;;;"}
|
|
@@ -362,6 +362,11 @@
|
|
|
362
362
|
* @private
|
|
363
363
|
*/
|
|
364
364
|
this.rootSchema = void 0;
|
|
365
|
+
/** The root schema resolved top level refs
|
|
366
|
+
*
|
|
367
|
+
* @private
|
|
368
|
+
*/
|
|
369
|
+
this.resolvedRootSchema = void 0;
|
|
365
370
|
/** The `ValidatorFunctions` map used to construct this validator
|
|
366
371
|
*
|
|
367
372
|
* @private
|
|
@@ -381,6 +386,7 @@
|
|
|
381
386
|
this.validateFns = validateFns;
|
|
382
387
|
this.localizer = localizer;
|
|
383
388
|
this.mainValidator = this.getValidator(rootSchema);
|
|
389
|
+
this.resolvedRootSchema = utils.retrieveSchema(this, rootSchema, rootSchema);
|
|
384
390
|
}
|
|
385
391
|
/** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator
|
|
386
392
|
* functions.
|
|
@@ -418,7 +424,7 @@
|
|
|
418
424
|
* @throws - Error when the schema provided does not match the base schema of the precompiled validator
|
|
419
425
|
*/;
|
|
420
426
|
_proto.rawValidation = function rawValidation(schema, formData) {
|
|
421
|
-
if (!isEqual__default["default"](schema, this.
|
|
427
|
+
if (!isEqual__default["default"](schema, this.resolvedRootSchema)) {
|
|
422
428
|
throw new Error('The schema associated with the precompiled schema differs from the schema provided for validation');
|
|
423
429
|
}
|
|
424
430
|
this.mainValidator(formData);
|
|
@@ -461,6 +467,9 @@
|
|
|
461
467
|
if (!isEqual__default["default"](rootSchema, this.rootSchema)) {
|
|
462
468
|
throw new Error('The schema associated with the precompiled validator differs from the rootSchema provided for validation');
|
|
463
469
|
}
|
|
470
|
+
if (get__default["default"](schema, utils.ID_KEY) === utils.JUNK_OPTION_ID) {
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
464
473
|
var validator = this.getValidator(schema);
|
|
465
474
|
return validator(formData);
|
|
466
475
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator-ajv8.umd.development.js","sources":["../src/createAjvInstance.ts","../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/precompiledValidator.ts","../src/createPrecompiledValidator.ts","../src/index.ts"],"sourcesContent":["import Ajv, { Options } from 'ajv';\nimport addFormats, { FormatsPluginOptions } from 'ajv-formats';\nimport isObject from 'lodash/isObject';\n\nimport { CustomValidatorOptionsType } from './types';\nimport { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG } from '@rjsf/utils';\n\nexport const AJV_CONFIG: Options = {\n allErrors: true,\n multipleOfPrecision: 8,\n strict: false,\n verbose: true,\n} as const;\nexport const COLOR_FORMAT_REGEX =\n /^(#?([0-9A-Fa-f]{3}){1,2}\\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\\(\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*\\))|(rgb\\(\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*\\)))$/;\nexport const DATA_URL_FORMAT_REGEX = /^data:([a-z]+\\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;\n\n/** Creates an Ajv version 8 implementation object with standard support for the 'color` and `data-url` custom formats.\n * If `additionalMetaSchemas` are provided then the Ajv instance is modified to add each of the meta schemas in the\n * list. If `customFormats` are provided then those additional formats are added to the list of supported formats. If\n * `ajvOptionsOverrides` are provided then they are spread on top of the default `AJV_CONFIG` options when constructing\n * the `Ajv` instance. With Ajv v8, the JSON Schema formats are not provided by default, but can be plugged in. By\n * default, all formats from the `ajv-formats` library are added. To disable this capability, set the `ajvFormatOptions`\n * parameter to `false`. Additionally, you can configure the `ajv-formats` by providing a custom set of\n * [format options](https://github.com/ajv-validator/ajv-formats) to the `ajvFormatOptions` parameter.\n *\n * @param [additionalMetaSchemas] - The list of additional meta schemas that the validator can access\n * @param [customFormats] - The set of additional custom formats that the validator will support\n * @param [ajvOptionsOverrides={}] - The set of validator config override options\n * @param [ajvFormatOptions] - The `ajv-format` options to use when adding formats to `ajv`; pass `false` to disable it\n * @param [AjvClass] - The `Ajv` class to use when creating the validator instance\n */\nexport default function createAjvInstance(\n additionalMetaSchemas?: CustomValidatorOptionsType['additionalMetaSchemas'],\n customFormats?: CustomValidatorOptionsType['customFormats'],\n ajvOptionsOverrides: CustomValidatorOptionsType['ajvOptionsOverrides'] = {},\n ajvFormatOptions?: FormatsPluginOptions | false,\n AjvClass: typeof Ajv = Ajv\n) {\n const ajv = new AjvClass({ ...AJV_CONFIG, ...ajvOptionsOverrides });\n if (ajvFormatOptions) {\n addFormats(ajv, ajvFormatOptions);\n } else if (ajvFormatOptions !== false) {\n addFormats(ajv);\n }\n\n // add custom formats\n ajv.addFormat('data-url', DATA_URL_FORMAT_REGEX);\n ajv.addFormat('color', COLOR_FORMAT_REGEX);\n\n // Add RJSF-specific additional properties keywords so Ajv doesn't report errors if strict is enabled.\n ajv.addKeyword(ADDITIONAL_PROPERTY_FLAG);\n ajv.addKeyword(RJSF_ADDITONAL_PROPERTIES_FLAG);\n\n // add more schemas to validate against\n if (Array.isArray(additionalMetaSchemas)) {\n ajv.addMetaSchema(additionalMetaSchemas);\n }\n\n // add more custom formats to validate against\n if (isObject(customFormats)) {\n Object.keys(customFormats).forEach((formatName) => {\n ajv.addFormat(formatName, customFormats[formatName]);\n });\n }\n\n return ajv;\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n","import customizeValidator from './customizeValidator';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n"],"names":["AJV_CONFIG","allErrors","multipleOfPrecision","strict","verbose","COLOR_FORMAT_REGEX","DATA_URL_FORMAT_REGEX","createAjvInstance","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","ajv","_extends","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName","transformRJSFValidationErrors","errors","uiSchema","map","e","instancePath","keyword","params","schemaPath","parentSchema","rest","_objectWithoutPropertiesLoose","_excluded","_rest$message","message","property","replace","stack","trim","missingProperty","currentProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","invalidSchemaError","validationError","concat","errorSchema","toErrorSchema","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","_proto","prototype","toErrorList","fieldPath","rawValidation","compilationError","undefined","compiledValidator","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","result","console","warn","removeSchema","customizeValidator","AJV8PrecompiledValidator","validateFns","mainValidator","getValidator","key","hashForSchema","Error","isEqual","createPrecompiledValidator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOO,IAAMA,UAAU,GAAY;EACjCC,EAAAA,SAAS,EAAE,IAAI;EACfC,EAAAA,mBAAmB,EAAE,CAAC;EACtBC,EAAAA,MAAM,EAAE,KAAK;EACbC,EAAAA,OAAO,EAAE,IAAA;GACD,CAAA;EACH,IAAMC,kBAAkB,GAC7B,4YAA4Y,CAAA;EACvY,IAAMC,qBAAqB,GAAG,2DAA2D,CAAA;EAEhG;;;;;;;;;;;;;;EAcG;EACqB,SAAAC,iBAAiBA,CACvCC,qBAA2E,EAC3EC,aAA2D,EAC3DC,qBACAC,gBAA+C,EAC/CC,UAA0B;EAAA,EAAA,IAF1BF;MAAAA,sBAAyE,EAAE,CAAA;EAAA,GAAA;EAAA,EAAA,IAE3EE;EAAAA,IAAAA,WAAuBC,uBAAG,CAAA;EAAA,GAAA;IAE1B,IAAMC,GAAG,GAAG,IAAIF,QAAQ,CAAAG,QAAA,CAAA,EAAA,EAAMf,UAAU,EAAKU,mBAAmB,CAAE,CAAC,CAAA;EACnE,EAAA,IAAIC,gBAAgB,EAAE;EACpBK,IAAAA,8BAAU,CAACF,GAAG,EAAEH,gBAAgB,CAAC,CAAA;EAClC,GAAA,MAAM,IAAIA,gBAAgB,KAAK,KAAK,EAAE;MACrCK,8BAAU,CAACF,GAAG,CAAC,CAAA;EAChB,GAAA;EAED;EACAA,EAAAA,GAAG,CAACG,SAAS,CAAC,UAAU,EAAEX,qBAAqB,CAAC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AA;EACnE,IAAA,OAAOH,0BAA0B,CAAC,IAAI,EAAEE,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,cAAc,EAAEC,eAAe,EAAEhC,QAAQ,CAAC,CAAA;EACjH,GAAA;EAEA;;;;;;;;;EASG,MATH;IAAAkD,MAAA,CAUAa,OAAO,GAAP,SAAAA,OAAAA,CAAQjC,MAAS,EAAED,QAAuB,EAAEmC,UAAa,EAAA;MACvD,IAAI,CAACmB,2BAAO,CAACnB,UAAU,EAAE,IAAI,CAACA,UAAU,CAAC,EAAE;EACzC,MAAA,MAAM,IAAIkB,KAAK,CACb,0GAA0G,CAC3G,CAAA;EACF,KAAA;EACD,IAAA,IAAMvD,SAAS,GAAG,IAAI,CAACoD,YAAY,CAACjD,MAAM,CAAC,CAAA;MAC3C,OAAOH,SAAS,CAACE,QAAQ,CAAC,CAAA;KAC3B,CAAA;EAAA,EAAA,OAAA+C,wBAAA,CAAA;EAAA,CAAA,EAAA;;EC3JH;;;;;;;;;;EAUG;EACqB,SAAAQ,0BAA0BA,CAIhDP,WAA+B,EAAEb,UAAa,EAAEf,SAAqB,EAAA;IACrE,OAAO,IAAI2B,wBAAwB,CAAUC,WAAW,EAAEb,UAAU,EAAEf,SAAS,CAAC,CAAA;EAClF;;AChBA,cAAe0B,aAAAA,kBAAkB,EAAE;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"validator-ajv8.umd.development.js","sources":["../src/createAjvInstance.ts","../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/precompiledValidator.ts","../src/createPrecompiledValidator.ts","../src/index.ts"],"sourcesContent":["import Ajv, { Options } from 'ajv';\nimport addFormats, { FormatsPluginOptions } from 'ajv-formats';\nimport isObject from 'lodash/isObject';\n\nimport { CustomValidatorOptionsType } from './types';\nimport { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG } from '@rjsf/utils';\n\nexport const AJV_CONFIG: Options = {\n allErrors: true,\n multipleOfPrecision: 8,\n strict: false,\n verbose: true,\n} as const;\nexport const COLOR_FORMAT_REGEX =\n /^(#?([0-9A-Fa-f]{3}){1,2}\\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\\(\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*\\))|(rgb\\(\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*\\)))$/;\nexport const DATA_URL_FORMAT_REGEX = /^data:([a-z]+\\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;\n\n/** Creates an Ajv version 8 implementation object with standard support for the 'color` and `data-url` custom formats.\n * If `additionalMetaSchemas` are provided then the Ajv instance is modified to add each of the meta schemas in the\n * list. If `customFormats` are provided then those additional formats are added to the list of supported formats. If\n * `ajvOptionsOverrides` are provided then they are spread on top of the default `AJV_CONFIG` options when constructing\n * the `Ajv` instance. With Ajv v8, the JSON Schema formats are not provided by default, but can be plugged in. By\n * default, all formats from the `ajv-formats` library are added. To disable this capability, set the `ajvFormatOptions`\n * parameter to `false`. Additionally, you can configure the `ajv-formats` by providing a custom set of\n * [format options](https://github.com/ajv-validator/ajv-formats) to the `ajvFormatOptions` parameter.\n *\n * @param [additionalMetaSchemas] - The list of additional meta schemas that the validator can access\n * @param [customFormats] - The set of additional custom formats that the validator will support\n * @param [ajvOptionsOverrides={}] - The set of validator config override options\n * @param [ajvFormatOptions] - The `ajv-format` options to use when adding formats to `ajv`; pass `false` to disable it\n * @param [AjvClass] - The `Ajv` class to use when creating the validator instance\n */\nexport default function createAjvInstance(\n additionalMetaSchemas?: CustomValidatorOptionsType['additionalMetaSchemas'],\n customFormats?: CustomValidatorOptionsType['customFormats'],\n ajvOptionsOverrides: CustomValidatorOptionsType['ajvOptionsOverrides'] = {},\n ajvFormatOptions?: FormatsPluginOptions | false,\n AjvClass: typeof Ajv = Ajv\n) {\n const ajv = new AjvClass({ ...AJV_CONFIG, ...ajvOptionsOverrides });\n if (ajvFormatOptions) {\n addFormats(ajv, ajvFormatOptions);\n } else if (ajvFormatOptions !== false) {\n addFormats(ajv);\n }\n\n // add custom formats\n ajv.addFormat('data-url', DATA_URL_FORMAT_REGEX);\n ajv.addFormat('color', COLOR_FORMAT_REGEX);\n\n // Add RJSF-specific additional properties keywords so Ajv doesn't report errors if strict is enabled.\n ajv.addKeyword(ADDITIONAL_PROPERTY_FLAG);\n ajv.addKeyword(RJSF_ADDITONAL_PROPERTIES_FLAG);\n\n // add more schemas to validate against\n if (Array.isArray(additionalMetaSchemas)) {\n ajv.addMetaSchema(additionalMetaSchemas);\n }\n\n // add more custom formats to validate against\n if (isObject(customFormats)) {\n Object.keys(customFormats).forEach((formatName) => {\n ajv.addFormat(formatName, customFormats[formatName]);\n });\n }\n\n return ajv;\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n JUNK_OPTION_ID,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n retrieveSchema,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The root schema resolved top level refs\n *\n * @private\n */\n readonly resolvedRootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n this.resolvedRootSchema = retrieveSchema(this, rootSchema, rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.resolvedRootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n if (get(schema, ID_KEY) === JUNK_OPTION_ID) {\n return false;\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n","import customizeValidator from './customizeValidator';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n"],"names":["AJV_CONFIG","allErrors","multipleOfPrecision","strict","verbose","COLOR_FORMAT_REGEX","DATA_URL_FORMAT_REGEX","createAjvInstance","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","ajv","_extends","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName","transformRJSFValidationErrors","errors","uiSchema","map","e","instancePath","keyword","params","schemaPath","parentSchema","rest","_objectWithoutPropertiesLoose","_excluded","_rest$message","message","property","replace","stack","trim","missingProperty","currentProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","invalidSchemaError","validationError","concat","errorSchema","toErrorSchema","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","_proto","prototype","toErrorList","fieldPath","rawValidation","compilationError","undefined","compiledValidator","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","result","console","warn","removeSchema","customizeValidator","AJV8PrecompiledValidator","validateFns","resolvedRootSchema","mainValidator","getValidator","retrieveSchema","key","hashForSchema","Error","isEqual","JUNK_OPTION_ID","createPrecompiledValidator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOO,IAAMA,UAAU,GAAY;EACjCC,EAAAA,SAAS,EAAE,IAAI;EACfC,EAAAA,mBAAmB,EAAE,CAAC;EACtBC,EAAAA,MAAM,EAAE,KAAK;EACbC,EAAAA,OAAO,EAAE,IAAA;GACD,CAAA;EACH,IAAMC,kBAAkB,GAC7B,4YAA4Y,CAAA;EACvY,IAAMC,qBAAqB,GAAG,2DAA2D,CAAA;EAEhG;;;;;;;;;;;;;;EAcG;EACqB,SAAAC,iBAAiBA,CACvCC,qBAA2E,EAC3EC,aAA2D,EAC3DC,qBACAC,gBAA+C,EAC/CC,UAA0B;EAAA,EAAA,IAF1BF;MAAAA,sBAAyE,EAAE,CAAA;EAAA,GAAA;EAAA,EAAA,IAE3EE;EAAAA,IAAAA,WAAuBC,uBAAG,CAAA;EAAA,GAAA;IAE1B,IAAMC,GAAG,GAAG,IAAIF,QAAQ,CAAAG,QAAA,CAAA,EAAA,EAAMf,UAAU,EAAKU,mBAAmB,CAAE,CAAC,CAAA;EACnE,EAAA,IAAIC,gB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AO,IAAI2B,wBAAwB,CAAUC,WAAW,EAAEb,UAAU,EAAEf,SAAS,CAAC,CAAA;EAClF;;AChBA,cAAe0B,aAAAA,kBAAkB,EAAE;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@rjsf/utils"),require("ajv"),require("ajv-formats"),require("lodash-es/isObject"),require("lodash-es/get"),require("lodash-es/isEqual")):"function"==typeof define&&define.amd?define(["exports","@rjsf/utils","ajv","ajv-formats","lodash-es/isObject","lodash-es/get","lodash-es/isEqual"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self)["@rjsf/validator-ajv8"]={},r.utils,r.Ajv,r.addFormats,r.isObject,r.get,r.isEqual)}(this,(function(r,e,t,a,i,o,s){"use strict";function n(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var l=n(t),d=n(a),c=n(i),
|
|
1
|
+
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@rjsf/utils"),require("ajv"),require("ajv-formats"),require("lodash-es/isObject"),require("lodash-es/get"),require("lodash-es/isEqual")):"function"==typeof define&&define.amd?define(["exports","@rjsf/utils","ajv","ajv-formats","lodash-es/isObject","lodash-es/get","lodash-es/isEqual"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self)["@rjsf/validator-ajv8"]={},r.utils,r.Ajv,r.addFormats,r.isObject,r.get,r.isEqual)}(this,(function(r,e,t,a,i,o,s){"use strict";function n(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var l=n(t),d=n(a),c=n(i),h=n(o),u=n(s);function f(){return f=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},f.apply(this,arguments)}var v={allErrors:!0,multipleOfPrecision:8,strict:!1,verbose:!0},m=/^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,p=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/,g=["instancePath","keyword","params","schemaPath","parentSchema"];function y(r,t,a,i,o,s,n){var l=t.validationError,d=function(r,t){return void 0===r&&(r=[]),r.map((function(r){var a=r.instancePath,i=r.keyword,o=r.params,s=r.schemaPath,n=r.parentSchema,l=function(r,e){if(null==r)return{};var t,a,i={},o=Object.keys(r);for(a=0;a<o.length;a++)e.indexOf(t=o[a])>=0||(i[t]=r[t]);return i}(r,g).message,d=void 0===l?"":l,c=a.replace(/\//g,"."),u=(c+" "+d).trim();if("missingProperty"in o){var f=o.missingProperty,v=e.getUiOptions(h.default(t,""+(c=c?c+"."+o.missingProperty:o.missingProperty).replace(/^\./,""))).title;if(v)d=d.replace(f,v);else{var m=h.default(n,[e.PROPERTIES_KEY,f,"title"]);m&&(d=d.replace(f,m))}u=d}else{var p=e.getUiOptions(h.default(t,""+c.replace(/^\./,""))).title;if(p)u=("'"+p+"' "+d).trim();else{var y=null==n?void 0:n.title;y&&(u=("'"+y+"' "+d).trim())}}return{name:i,property:c,message:d,params:o,stack:u,schemaPath:s}}))}(t.errors,n);l&&(d=[].concat(d,[{stack:l.message}])),"function"==typeof s&&(d=s(d,n));var c=e.toErrorSchema(d);if(l&&(c=f({},c,{$schema:{__errors:[l.message]}})),"function"!=typeof o)return{errors:d,errorSchema:c};var u=e.getDefaultFormState(r,i,a,i,!0),v=o(u,e.createErrorHandler(u),n),m=e.unwrapErrorHandler(v);return e.validationDataMerge({errors:d,errorSchema:c},m)}var E=function(){function r(r,t){this.ajv=void 0,this.localizer=void 0,this.ajv=function(r,t,a,i,o){void 0===a&&(a={}),void 0===o&&(o=l.default);var s=new o(f({},v,a));return i?d.default(s,i):!1!==i&&d.default(s),s.addFormat("data-url",p),s.addFormat("color",m),s.addKeyword(e.ADDITIONAL_PROPERTY_FLAG),s.addKeyword(e.RJSF_ADDITONAL_PROPERTIES_FLAG),Array.isArray(r)&&s.addMetaSchema(r),c.default(t)&&Object.keys(t).forEach((function(r){s.addFormat(r,t[r])})),s}(r.additionalMetaSchemas,r.customFormats,r.ajvOptionsOverrides,r.ajvFormatOptions,r.AjvClass),this.localizer=t}var t=r.prototype;return t.toErrorList=function(r,t){return void 0===t&&(t=[]),e.toErrorList(r,t)},t.rawValidation=function(r,t){var a,i,o=void 0;r[e.ID_KEY]&&(a=this.ajv.getSchema(r[e.ID_KEY]));try{void 0===a&&(a=this.ajv.compile(r)),a(t)}catch(r){o=r}return a&&("function"==typeof this.localizer&&this.localizer(a.errors),i=a.errors||void 0,a.errors=null),{errors:i,validationError:o}},t.validateFormData=function(r,e,t,a,i){return y(this,this.rawValidation(e,r),r,e,t,a,i)},t.isValid=function(r,t,a){var i,o=null!=(i=a[e.ID_KEY])?i:e.ROOT_SCHEMA_PREFIX;try{void 0===this.ajv.getSchema(o)&&this.ajv.addSchema(a,o);var s,n=e.withIdRefPrefix(r);return n[e.ID_KEY]&&(s=this.ajv.getSchema(n[e.ID_KEY])),void 0===s&&(s=this.ajv.compile(n)),s(t)}catch(r){return console.warn("Error encountered compiling schema:",r),!1}finally{this.ajv.removeSchema(o)}},r}();function j(r,e){return void 0===r&&(r={}),new E(r,e)}var b=function(){function r(r,t,a){this.rootSchema=void 0,this.resolvedRootSchema=void 0,this.validateFns=void 0,this.mainValidator=void 0,this.localizer=void 0,this.rootSchema=t,this.validateFns=r,this.localizer=a,this.mainValidator=this.getValidator(t),this.resolvedRootSchema=e.retrieveSchema(this,t,t)}var t=r.prototype;return t.getValidator=function(r){var t=h.default(r,e.ID_KEY)||e.hashForSchema(r),a=this.validateFns[t];if(!a)throw new Error('No precompiled validator function was found for the given schema for "'+t+'"');return a},t.toErrorList=function(r,t){return void 0===t&&(t=[]),e.toErrorList(r,t)},t.rawValidation=function(r,e){if(!u.default(r,this.resolvedRootSchema))throw new Error("The schema associated with the precompiled schema differs from the schema provided for validation");this.mainValidator(e),"function"==typeof this.localizer&&this.localizer(this.mainValidator.errors);var t=this.mainValidator.errors||void 0;return this.mainValidator.errors=null,{errors:t}},t.validateFormData=function(r,e,t,a,i){return y(this,this.rawValidation(e,r),r,e,t,a,i)},t.isValid=function(r,t,a){if(!u.default(a,this.rootSchema))throw new Error("The schema associated with the precompiled validator differs from the rootSchema provided for validation");return h.default(r,e.ID_KEY)!==e.JUNK_OPTION_ID&&this.getValidator(r)(t)},r}(),w=j();r.createPrecompiledValidator=function(r,e,t){return new b(r,e,t)},r.customizeValidator=j,r.default=w,Object.defineProperty(r,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=validator-ajv8.umd.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator-ajv8.umd.production.min.js","sources":["../src/createAjvInstance.ts","../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/precompiledValidator.ts","../src/index.ts","../src/createPrecompiledValidator.ts"],"sourcesContent":["import Ajv, { Options } from 'ajv';\nimport addFormats, { FormatsPluginOptions } from 'ajv-formats';\nimport isObject from 'lodash/isObject';\n\nimport { CustomValidatorOptionsType } from './types';\nimport { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG } from '@rjsf/utils';\n\nexport const AJV_CONFIG: Options = {\n allErrors: true,\n multipleOfPrecision: 8,\n strict: false,\n verbose: true,\n} as const;\nexport const COLOR_FORMAT_REGEX =\n /^(#?([0-9A-Fa-f]{3}){1,2}\\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\\(\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*\\))|(rgb\\(\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*\\)))$/;\nexport const DATA_URL_FORMAT_REGEX = /^data:([a-z]+\\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;\n\n/** Creates an Ajv version 8 implementation object with standard support for the 'color` and `data-url` custom formats.\n * If `additionalMetaSchemas` are provided then the Ajv instance is modified to add each of the meta schemas in the\n * list. If `customFormats` are provided then those additional formats are added to the list of supported formats. If\n * `ajvOptionsOverrides` are provided then they are spread on top of the default `AJV_CONFIG` options when constructing\n * the `Ajv` instance. With Ajv v8, the JSON Schema formats are not provided by default, but can be plugged in. By\n * default, all formats from the `ajv-formats` library are added. To disable this capability, set the `ajvFormatOptions`\n * parameter to `false`. Additionally, you can configure the `ajv-formats` by providing a custom set of\n * [format options](https://github.com/ajv-validator/ajv-formats) to the `ajvFormatOptions` parameter.\n *\n * @param [additionalMetaSchemas] - The list of additional meta schemas that the validator can access\n * @param [customFormats] - The set of additional custom formats that the validator will support\n * @param [ajvOptionsOverrides={}] - The set of validator config override options\n * @param [ajvFormatOptions] - The `ajv-format` options to use when adding formats to `ajv`; pass `false` to disable it\n * @param [AjvClass] - The `Ajv` class to use when creating the validator instance\n */\nexport default function createAjvInstance(\n additionalMetaSchemas?: CustomValidatorOptionsType['additionalMetaSchemas'],\n customFormats?: CustomValidatorOptionsType['customFormats'],\n ajvOptionsOverrides: CustomValidatorOptionsType['ajvOptionsOverrides'] = {},\n ajvFormatOptions?: FormatsPluginOptions | false,\n AjvClass: typeof Ajv = Ajv\n) {\n const ajv = new AjvClass({ ...AJV_CONFIG, ...ajvOptionsOverrides });\n if (ajvFormatOptions) {\n addFormats(ajv, ajvFormatOptions);\n } else if (ajvFormatOptions !== false) {\n addFormats(ajv);\n }\n\n // add custom formats\n ajv.addFormat('data-url', DATA_URL_FORMAT_REGEX);\n ajv.addFormat('color', COLOR_FORMAT_REGEX);\n\n // Add RJSF-specific additional properties keywords so Ajv doesn't report errors if strict is enabled.\n ajv.addKeyword(ADDITIONAL_PROPERTY_FLAG);\n ajv.addKeyword(RJSF_ADDITONAL_PROPERTIES_FLAG);\n\n // add more schemas to validate against\n if (Array.isArray(additionalMetaSchemas)) {\n ajv.addMetaSchema(additionalMetaSchemas);\n }\n\n // add more custom formats to validate against\n if (isObject(customFormats)) {\n Object.keys(customFormats).forEach((formatName) => {\n ajv.addFormat(formatName, customFormats[formatName]);\n });\n }\n\n return ajv;\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import customizeValidator from './customizeValidator';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n"],"names":["AJV_CONFIG","allErrors","multipleOfPrecision","strict","verbose","COLOR_FORMAT_REGEX","DATA_URL_FORMAT_REGEX","processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","uiSchema","invalidSchemaError","validationError","errors","map","e","instancePath","keyword","params","schemaPath","parentSchema","_rest$message","_objectWithoutPropertiesLoose","_excluded","message","property","replace","stack","trim","currentProperty","missingProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","transformRJSFValidationErrors","concat","errorSchema","toErrorSchema","_extends","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","this","ajv","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName","createAjvInstance","_proto","prototype","toErrorList","fieldPath","rawValidation","compiledValidator","compilationError","undefined","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","console","warn","removeSchema","customizeValidator","AJV8PrecompiledValidator","validateFns","mainValidator","getValidator","key","hashForSchema","Error","isEqual"],"mappings":"g4BAOO,IAAMA,EAAsB,CACjCC,WAAW,EACXC,oBAAqB,EACrBC,QAAQ,EACRC,SAAS,GAEEC,EACX,6YACWC,EAAwB,8HC+EvB,SAAUC,EAKtBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAEA,IAAyBC,EAAuBN,EAAxCO,gBACJC,WA5EJA,EAA4BH,GAC5B,YADwB,IAAxBG,IAAAA,EAAwB,IACjBA,EAAOC,KAAI,SAACC,GACjB,IAAQC,EAAqED,EAArEC,aAAcC,EAAuDF,EAAvDE,QAASC,EAA8CH,EAA9CG,OAAQC,EAAsCJ,EAAtCI,WAAYC,EAA0BL,EAA1BK,aACnDC,oIADwEC,CAAKP,EAACQ,GACxEC,QAAAA,OAAU,IAAHH,EAAG,GAAEA,EACdI,EAAWT,EAAaU,QAAQ,MAAO,KACvCC,GAAWF,MAAYD,GAAUI,OAErC,GAAI,oBAAqBV,EAAQ,CAE/B,IAAMW,EAA0BX,EAAOY,gBACjCC,EAAgBC,EAAAA,aAAaC,EAAG,QAACvB,EAAae,IAFpDA,EAAWA,EAAcA,EAAQ,IAAIP,EAAOY,gBAAoBZ,EAAOY,iBAEVJ,QAAQ,MAAO,MAAQQ,MAEpF,GAAIH,EACFP,EAAUA,EAAQE,QAAQG,EAAiBE,OACtC,CACL,IAAMI,EAAoBF,EAAAA,QAAIb,EAAc,CAACgB,EAAAA,eAAgBP,EAAiB,UAE1EM,IACFX,EAAUA,EAAQE,QAAQG,EAAiBM,GAE9C,CAEDR,EAAQH,CACT,KAAM,CACL,IAAMO,EAAgBC,EAAAA,aAAsBC,EAAG,QAACvB,EAAae,GAAAA,EAASC,QA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ACxB,MAAM,IAAIiB,MACR,qGAGJrD,KAAKiD,cAAclG,GAEW,mBAAnBiD,KAAKD,WACdC,KAAKD,UAAUC,KAAKiD,cAAc3F,QAEpC,IAAMA,EAAS0C,KAAKiD,cAAc3F,aAAUuE,EAK5C,OAFA7B,KAAKiD,cAAc3F,OAAS,KAErB,CAAEA,OAAQA,EACnB,EAEAgE,EAWAY,iBAAA,SACEnF,EACAC,EACAC,EACAC,EACAC,GAGA,OAAOP,EAA2BoD,KADhBA,KAAK0B,cAA2B1E,EAAQD,GACPA,EAAUC,EAAQC,EAAgBC,EAAiBC,EACxG,EAEAmE,EAUAa,QAAA,SAAQnF,EAAWD,EAAyBqF,GAC1C,IAAKkB,EAAAA,QAAQlB,EAAYpC,KAAKoC,YAC5B,MAAM,IAAIiB,MACR,4GAIJ,OADkBrD,KAAKkD,aAAalG,EAC7BH,CAAUE,IAClBgG,CAAA,CAxI0C,GClB9BD,EAAAA,iCCUS,SAItBE,EAAiCZ,EAAerC,GAChD,OAAO,IAAIgD,EAAkCC,EAAaZ,EAAYrC,EACxE"}
|
|
1
|
+
{"version":3,"file":"validator-ajv8.umd.production.min.js","sources":["../src/createAjvInstance.ts","../src/processRawValidationErrors.ts","../src/validator.ts","../src/customizeValidator.ts","../src/precompiledValidator.ts","../src/index.ts","../src/createPrecompiledValidator.ts"],"sourcesContent":["import Ajv, { Options } from 'ajv';\nimport addFormats, { FormatsPluginOptions } from 'ajv-formats';\nimport isObject from 'lodash/isObject';\n\nimport { CustomValidatorOptionsType } from './types';\nimport { ADDITIONAL_PROPERTY_FLAG, RJSF_ADDITONAL_PROPERTIES_FLAG } from '@rjsf/utils';\n\nexport const AJV_CONFIG: Options = {\n allErrors: true,\n multipleOfPrecision: 8,\n strict: false,\n verbose: true,\n} as const;\nexport const COLOR_FORMAT_REGEX =\n /^(#?([0-9A-Fa-f]{3}){1,2}\\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\\(\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*,\\s*\\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\b\\s*\\))|(rgb\\(\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*,\\s*(\\d?\\d%|100%)+\\s*\\)))$/;\nexport const DATA_URL_FORMAT_REGEX = /^data:([a-z]+\\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;\n\n/** Creates an Ajv version 8 implementation object with standard support for the 'color` and `data-url` custom formats.\n * If `additionalMetaSchemas` are provided then the Ajv instance is modified to add each of the meta schemas in the\n * list. If `customFormats` are provided then those additional formats are added to the list of supported formats. If\n * `ajvOptionsOverrides` are provided then they are spread on top of the default `AJV_CONFIG` options when constructing\n * the `Ajv` instance. With Ajv v8, the JSON Schema formats are not provided by default, but can be plugged in. By\n * default, all formats from the `ajv-formats` library are added. To disable this capability, set the `ajvFormatOptions`\n * parameter to `false`. Additionally, you can configure the `ajv-formats` by providing a custom set of\n * [format options](https://github.com/ajv-validator/ajv-formats) to the `ajvFormatOptions` parameter.\n *\n * @param [additionalMetaSchemas] - The list of additional meta schemas that the validator can access\n * @param [customFormats] - The set of additional custom formats that the validator will support\n * @param [ajvOptionsOverrides={}] - The set of validator config override options\n * @param [ajvFormatOptions] - The `ajv-format` options to use when adding formats to `ajv`; pass `false` to disable it\n * @param [AjvClass] - The `Ajv` class to use when creating the validator instance\n */\nexport default function createAjvInstance(\n additionalMetaSchemas?: CustomValidatorOptionsType['additionalMetaSchemas'],\n customFormats?: CustomValidatorOptionsType['customFormats'],\n ajvOptionsOverrides: CustomValidatorOptionsType['ajvOptionsOverrides'] = {},\n ajvFormatOptions?: FormatsPluginOptions | false,\n AjvClass: typeof Ajv = Ajv\n) {\n const ajv = new AjvClass({ ...AJV_CONFIG, ...ajvOptionsOverrides });\n if (ajvFormatOptions) {\n addFormats(ajv, ajvFormatOptions);\n } else if (ajvFormatOptions !== false) {\n addFormats(ajv);\n }\n\n // add custom formats\n ajv.addFormat('data-url', DATA_URL_FORMAT_REGEX);\n ajv.addFormat('color', COLOR_FORMAT_REGEX);\n\n // Add RJSF-specific additional properties keywords so Ajv doesn't report errors if strict is enabled.\n ajv.addKeyword(ADDITIONAL_PROPERTY_FLAG);\n ajv.addKeyword(RJSF_ADDITONAL_PROPERTIES_FLAG);\n\n // add more schemas to validate against\n if (Array.isArray(additionalMetaSchemas)) {\n ajv.addMetaSchema(additionalMetaSchemas);\n }\n\n // add more custom formats to validate against\n if (isObject(customFormats)) {\n Object.keys(customFormats).forEach((formatName) => {\n ajv.addFormat(formatName, customFormats[formatName]);\n });\n }\n\n return ajv;\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport {\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\n\nexport type RawValidationErrorsType<Result = any> = { errors?: Result[]; validationError?: Error };\n\n/** Transforming the error output from ajv to format used by @rjsf/utils.\n * At some point, components should be updated to support ajv.\n *\n * @param errors - The list of AJV errors to convert to `RJSFValidationErrors`\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(errors: ErrorObject[] = [], uiSchema?: UiSchema<T, S, F>): RJSFValidationError[] {\n return errors.map((e: ErrorObject) => {\n const { instancePath, keyword, params, schemaPath, parentSchema, ...rest } = e;\n let { message = '' } = rest;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n\n if ('missingProperty' in params) {\n property = property ? `${property}.${params.missingProperty}` : params.missingProperty;\n const currentProperty: string = params.missingProperty;\n const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n message = message.replace(currentProperty, uiSchemaTitle);\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n\n if (parentSchemaTitle) {\n message = message.replace(currentProperty, parentSchemaTitle);\n }\n }\n\n stack = message;\n } else {\n const uiSchemaTitle = getUiOptions<T, S, F>(get(uiSchema, `${property.replace(/^\\./, '')}`)).title;\n\n if (uiSchemaTitle) {\n stack = `'${uiSchemaTitle}' ${message}`.trim();\n } else {\n const parentSchemaTitle = parentSchema?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n }\n }\n }\n\n // put data in expected format\n return {\n name: keyword,\n property,\n message,\n params, // specific to ajv\n stack,\n schemaPath,\n };\n });\n}\n\n/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param validator - The `ValidatorType` implementation used for the `getDefaultFormState()` call\n * @param rawErrors - The list of raw `ErrorObject`s to process\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\nexport default function processRawValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(\n validator: ValidatorType<T, S, F>,\n rawErrors: RawValidationErrorsType<ErrorObject>,\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema);\n\n if (invalidSchemaError) {\n errors = [...errors, { stack: invalidSchemaError!.message }];\n }\n if (typeof transformErrors === 'function') {\n errors = transformErrors(errors, uiSchema);\n }\n\n let errorSchema = toErrorSchema<T>(errors);\n\n if (invalidSchemaError) {\n errorSchema = {\n ...errorSchema,\n $schema: {\n __errors: [invalidSchemaError!.message],\n },\n };\n }\n\n if (typeof customValidate !== 'function') {\n return { errors, errorSchema };\n }\n\n // Include form data with undefined values, which is required for custom validation.\n const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n","import Ajv, { ErrorObject, ValidateFunction } from 'ajv';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport createAjvInstance from './createAjvInstance';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses the AJV 8 validation mechanism.\n */\nexport default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The AJV instance to use for all validations\n *\n * @private\n */\n private ajv: Ajv;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8Validator` instance using the `options`\n *\n * @param options - The `CustomValidatorOptionsType` options that are used to create the AJV instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n */\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n const { additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass } = options;\n this.ajv = createAjvInstance(additionalMetaSchemas, customFormats, ajvOptionsOverrides, ajvFormatOptions, AjvClass);\n this.localizer = localizer;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined = undefined;\n let compiledValidator: ValidateFunction | undefined;\n if (schema[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schema[ID_KEY]);\n }\n try {\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schema);\n }\n compiledValidator(formData);\n } catch (err) {\n compilationError = err as Error;\n }\n\n let errors;\n if (compiledValidator) {\n if (typeof this.localizer === 'function') {\n this.localizer(compiledValidator.errors);\n }\n errors = compiledValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n compiledValidator.errors = null;\n }\n\n return {\n errors: errors as unknown as Result[],\n validationError: compilationError,\n };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or\n * false otherwise. If the schema is invalid, then this function will return\n * false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n const rootSchemaId = rootSchema[ID_KEY] ?? ROOT_SCHEMA_PREFIX;\n try {\n // add the rootSchema ROOT_SCHEMA_PREFIX as id.\n // then rewrite the schema ref's to point to the rootSchema\n // this accounts for the case where schema have references to models\n // that lives in the rootSchema but not in the schema in question.\n if (this.ajv.getSchema(rootSchemaId) === undefined) {\n this.ajv.addSchema(rootSchema, rootSchemaId);\n }\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n let compiledValidator: ValidateFunction | undefined;\n if (schemaWithIdRefPrefix[ID_KEY]) {\n compiledValidator = this.ajv.getSchema(schemaWithIdRefPrefix[ID_KEY]);\n }\n if (compiledValidator === undefined) {\n compiledValidator = this.ajv.compile(schemaWithIdRefPrefix);\n }\n const result = compiledValidator(formData);\n return result as boolean;\n } catch (e) {\n console.warn('Error encountered compiling schema:', e);\n return false;\n } finally {\n // TODO: A function should be called if the root schema changes so we don't have to remove and recompile the schema every run.\n // make sure we remove the rootSchema from the global ajv instance\n this.ajv.removeSchema(rootSchemaId);\n }\n }\n}\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { CustomValidatorOptionsType, Localizer } from './types';\nimport AJV8Validator from './validator';\n\n/** Creates and returns a customized implementation of the `ValidatorType` with the given customization `options` if\n * provided. If a `localizer` is provided, it is used to translate the messages generated by the underlying AJV\n * validation.\n *\n * @param [options={}] - The `CustomValidatorOptionsType` options that are used to create the `ValidatorType` instance\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The custom validator implementation resulting from the set of parameters provided\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8Validator<T, S, F>(options, localizer);\n}\n","import { ErrorObject } from 'ajv';\nimport get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n JUNK_OPTION_ID,\n RJSFSchema,\n StrictRJSFSchema,\n toErrorList,\n UiSchema,\n ValidationData,\n ValidatorType,\n retrieveSchema,\n} from '@rjsf/utils';\n\nimport { CompiledValidateFunction, Localizer, ValidatorFunctions } from './types';\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\n\n/** `ValidatorType` implementation that uses an AJV 8 precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ajv8` library.\n */\nexport default class AJV8PrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n> implements ValidatorType<T, S, F>\n{\n /** The root schema object used to construct this validator\n *\n * @private\n */\n readonly rootSchema: S;\n\n /** The root schema resolved top level refs\n *\n * @private\n */\n readonly resolvedRootSchema: S;\n\n /** The `ValidatorFunctions` map used to construct this validator\n *\n * @private\n */\n readonly validateFns: ValidatorFunctions;\n\n /** The main validator function associated with the base schema in the `precompiledValidator`\n *\n * @private\n */\n readonly mainValidator: CompiledValidateFunction;\n\n /** The Localizer function to use for localizing Ajv errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Constructs an `AJV8PrecompiledValidator` instance using the `validateFns` and `rootSchema`\n *\n * @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function\n * @param rootSchema - The root schema that was used with the `compileSchema()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.mainValidator = this.getValidator(rootSchema);\n this.resolvedRootSchema = retrieveSchema(this, rootSchema, rootSchema);\n }\n\n /** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator\n * functions.\n *\n * @param schema - The schema for which a precompiled validator function is desired\n * @returns - The precompiled validator function associated with this schema\n */\n getValidator(schema: S) {\n const key = get(schema, ID_KEY) || hashForSchema(schema);\n const validator = this.validateFns[key];\n if (!validator) {\n throw new Error(`No precompiled validator function was found for the given schema for \"${key}\"`);\n }\n return validator;\n }\n\n /** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in\n * the next major release.\n */\n toErrorList(errorSchema?: ErrorSchema<T>, fieldPath: string[] = []) {\n return toErrorList(errorSchema, fieldPath);\n }\n\n /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use\n * by the playground. Returns the `errors` from the validation\n *\n * @param schema - The schema against which to validate the form data * @param schema\n * @param formData - The form data to validate\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n if (!isEqual(schema, this.resolvedRootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled schema differs from the schema provided for validation'\n );\n }\n this.mainValidator(formData);\n\n if (typeof this.localizer === 'function') {\n this.localizer(this.mainValidator.errors);\n }\n const errors = this.mainValidator.errors || undefined;\n\n // Clear errors to prevent persistent errors, see #1104\n this.mainValidator.errors = null;\n\n return { errors: errors as unknown as Result[] };\n }\n\n /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives\n * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also\n * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and\n * transform them in what ever way it chooses.\n *\n * @param formData - The form data to validate\n * @param schema - The schema against which to validate the form data\n * @param [customValidate] - An optional function that is used to perform custom validation\n * @param [transformErrors] - An optional function that is used to transform errors after AJV validation\n * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`\n */\n validateFormData(\n formData: T | undefined,\n schema: S,\n customValidate?: CustomValidator<T, S, F>,\n transformErrors?: ErrorTransformer<T, S, F>,\n uiSchema?: UiSchema<T, S, F>\n ): ValidationData<T> {\n const rawErrors = this.rawValidation<ErrorObject>(schema, formData);\n return processRawValidationErrors(this, rawErrors, formData, schema, customValidate, transformErrors, uiSchema);\n }\n\n /** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is\n * invalid, then this function will return false.\n *\n * @param schema - The schema against which to validate the form data\n * @param formData - The form data to validate\n * @param rootSchema - The root schema used to provide $ref resolutions\n * @returns - true if the formData validates against the schema, false otherwise\n * @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there\n * isn't a precompiled validator function associated with the schema\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n if (!isEqual(rootSchema, this.rootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation'\n );\n }\n if (get(schema, ID_KEY) === JUNK_OPTION_ID) {\n return false;\n }\n const validator = this.getValidator(schema);\n return validator(formData);\n }\n}\n","import customizeValidator from './customizeValidator';\nimport createPrecompiledValidator from './createPrecompiledValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport * from './types';\n\nexport default customizeValidator();\n","import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport { Localizer, ValidatorFunctions } from './types';\nimport AJV8PrecompiledValidator from './precompiledValidator';\n\n/** Creates and returns a `ValidatorType` interface that is implemented with a precompiled validator. If a `localizer`\n * is provided, it is used to translate the messages generated by the underlying AJV validation.\n *\n * NOTE: The `validateFns` parameter is an object obtained by importing from a precompiled validation file created via\n * the `compileSchemaValidators()` function.\n *\n * @param validateFns - The map of the validation functions that are created by the `compileSchemaValidators()` function\n * @param rootSchema - The root schema that was used with the `compileSchemaValidators()` function\n * @param [localizer] - If provided, is used to localize a list of Ajv `ErrorObject`s\n * @returns - The precompiled validator implementation resulting from the set of parameters provided\n */\nexport default function createPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any\n>(validateFns: ValidatorFunctions, rootSchema: S, localizer?: Localizer): ValidatorType<T, S, F> {\n return new AJV8PrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer);\n}\n"],"names":["AJV_CONFIG","allErrors","multipleOfPrecision","strict","verbose","COLOR_FORMAT_REGEX","DATA_URL_FORMAT_REGEX","processRawValidationErrors","validator","rawErrors","formData","schema","customValidate","transformErrors","uiSchema","invalidSchemaError","validationError","errors","map","e","instancePath","keyword","params","schemaPath","parentSchema","_rest$message","_objectWithoutPropertiesLoose","_excluded","message","property","replace","stack","trim","currentProperty","missingProperty","uiSchemaTitle","getUiOptions","get","title","parentSchemaTitle","PROPERTIES_KEY","name","transformRJSFValidationErrors","concat","errorSchema","toErrorSchema","_extends","$schema","__errors","newFormData","getDefaultFormState","errorHandler","createErrorHandler","userErrorSchema","unwrapErrorHandler","validationDataMerge","AJV8Validator","options","localizer","this","ajv","additionalMetaSchemas","customFormats","ajvOptionsOverrides","ajvFormatOptions","AjvClass","Ajv","addFormats","addFormat","addKeyword","ADDITIONAL_PROPERTY_FLAG","RJSF_ADDITONAL_PROPERTIES_FLAG","Array","isArray","addMetaSchema","isObject","Object","keys","forEach","formatName","createAjvInstance","_proto","prototype","toErrorList","fieldPath","rawValidation","compiledValidator","compilationError","undefined","ID_KEY","getSchema","compile","err","validateFormData","isValid","rootSchema","_rootSchema$ID_KEY","rootSchemaId","ROOT_SCHEMA_PREFIX","addSchema","schemaWithIdRefPrefix","withIdRefPrefix","console","warn","removeSchema","customizeValidator","AJV8PrecompiledValidator","validateFns","resolvedRootSchema","mainValidator","getValidator","retrieveSchema","key","hashForSchema","Error","isEqual","JUNK_OPTION_ID"],"mappings":"g4BAOO,IAAMA,EAAsB,CACjCC,WAAW,EACXC,oBAAqB,EACrBC,QAAQ,EACRC,SAAS,GAEEC,EACX,6YACWC,EAAwB,8HC+EvB,SAAUC,EAKtBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAEA,IAAyBC,EAAuBN,EAAxCO,gBACJC,WA5EJA,EAA4BH,GAC5B,YADwB,IAAxBG,IAAAA,EAAwB,IACjBA,EAAOC,KAAI,SAACC,GACjB,IAAQC,EAAqED,EAArEC,aAAcC,EAAuDF,EAAvDE,QAASC,EAA8CH,EAA9CG,OAAQC,EAAsCJ,EAAtCI,WAAYC,EAA0BL,EAA1BK,aACnDC,oIADwEC,CAAKP,EAACQ,GACxEC,QAAAA,OAAU,IAAHH,EAAG,GAAEA,EACdI,EAAWT,EAAaU,QAAQ,MAAO,KACvCC,GAAWF,MAAYD,GAAUI,OAErC,GAAI,oBAAqBV,EAAQ,CAE/B,IAAMW,EAA0BX,EAAOY,gBACjCC,EAAgBC,EAAAA,aAAaC,EAAG,QAACvB,EAAae,IAFpDA,EAAWA,EAAcA,EAAQ,IAAIP,EAAOY,gBAAoBZ,EAAOY,iBAEVJ,QAAQ,MAAO,MAAQQ,MAEpF,GAAIH,EACFP,EAAUA,EAAQE,QAAQG,EAAiBE,OACtC,CACL,IAAMI,EAAoBF,EAAAA,QAAIb,EAAc,CAACgB,EAAAA,eAAgBP,EAAiB,UA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EF,yEAAAA,OAE3F,OAAOxG,CACT,EAEAyE,EAOAE,YAAA,SAAYvC,EAA8BwC,GACxC,YADwC,IAAAA,IAAAA,EAAsB,IACvDD,EAAWA,YAACvC,EAAawC,EAClC,EAEAH,EAOAI,cAAA,SAA4B1E,EAAWD,GACrC,IAAKyG,EAAAA,QAAQxG,EAAQgD,KAAKiD,oBACxB,MAAM,IAAIM,MACR,qGAGJvD,KAAKkD,cAAcnG,GAEW,mBAAnBiD,KAAKD,WACdC,KAAKD,UAAUC,KAAKkD,cAAc5F,QAEpC,IAAMA,EAAS0C,KAAKkD,cAAc5F,aAAUuE,EAK5C,OAFA7B,KAAKkD,cAAc5F,OAAS,KAErB,CAAEA,OAAQA,EACnB,EAEAgE,EAWAY,iBAAA,SACEnF,EACAC,EACAC,EACAC,EACAC,GAGA,OAAOP,EAA2BoD,KADhBA,KAAK0B,cAA2B1E,EAAQD,GACPA,EAAUC,EAAQC,EAAgBC,EAAiBC,EACxG,EAEAmE,EAUAa,QAAA,SAAQnF,EAAWD,EAAyBqF,GAC1C,IAAKoB,EAAAA,QAAQpB,EAAYpC,KAAKoC,YAC5B,MAAM,IAAImB,MACR,4GAGJ,OAAI7E,UAAI1B,EAAQ8E,EAAMA,UAAM2B,EAAAA,gBAGVzD,KAAKmD,aAAanG,EAC7BH,CAAUE,IAClBgG,CAAA,CAlJ0C,GCpB9BD,EAAAA,iCCUS,SAItBE,EAAiCZ,EAAerC,GAChD,OAAO,IAAIgD,EAAkCC,EAAaZ,EAAYrC,EACxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/validator-ajv8",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/validator-ajv8.esm.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -39,20 +39,21 @@
|
|
|
39
39
|
"@rjsf/utils": "5.7.x"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@babel/core": "^7.
|
|
42
|
+
"@babel/core": "^7.22.1",
|
|
43
43
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
44
|
+
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
44
45
|
"@babel/plugin-transform-modules-commonjs": "^7.21.5",
|
|
45
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
46
|
-
"@babel/preset-env": "^7.
|
|
47
|
-
"@babel/preset-react": "^7.
|
|
48
|
-
"@rjsf/utils": "^5.
|
|
46
|
+
"@babel/plugin-transform-react-jsx": "^7.22.3",
|
|
47
|
+
"@babel/preset-env": "^7.22.4",
|
|
48
|
+
"@babel/preset-react": "^7.22.3",
|
|
49
|
+
"@rjsf/utils": "^5.8.0",
|
|
49
50
|
"@types/jest-expect-message": "^1.1.0",
|
|
50
|
-
"@types/json-schema": "^7.0.
|
|
51
|
-
"@types/lodash": "^4.14.
|
|
51
|
+
"@types/json-schema": "^7.0.12",
|
|
52
|
+
"@types/lodash": "^4.14.195",
|
|
52
53
|
"dts-cli": "^1.6.3",
|
|
53
|
-
"eslint": "^8.
|
|
54
|
+
"eslint": "^8.42.0",
|
|
54
55
|
"jest-expect-message": "^1.1.3",
|
|
55
|
-
"rimraf": "^5.0.
|
|
56
|
+
"rimraf": "^5.0.1"
|
|
56
57
|
},
|
|
57
58
|
"publishConfig": {
|
|
58
59
|
"access": "public"
|
|
@@ -75,5 +76,5 @@
|
|
|
75
76
|
"url": "git+https://github.com/rjsf-team/react-jsonschema-form.git"
|
|
76
77
|
},
|
|
77
78
|
"license": "Apache-2.0",
|
|
78
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "a5d6f031b2cf8ff065ddb34e27cd2ef6f2beda7e"
|
|
79
80
|
}
|