@rjsf/validator-ata 6.6.1
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/README.md +94 -0
- package/dist/compileSchemaValidators.cjs +110 -0
- package/dist/compileSchemaValidators.cjs.map +7 -0
- package/dist/compileSchemaValidators.esm.js +79 -0
- package/dist/compileSchemaValidators.esm.js.map +7 -0
- package/dist/index.cjs +461 -0
- package/dist/index.cjs.map +7 -0
- package/dist/validator-ata.esm.js +450 -0
- package/dist/validator-ata.esm.js.map +7 -0
- package/dist/validator-ata.umd.js +422 -0
- package/lib/compileSchemaValidators.d.ts +16 -0
- package/lib/compileSchemaValidators.js +21 -0
- package/lib/compileSchemaValidators.js.map +1 -0
- package/lib/compileSchemaValidatorsCode.d.ts +13 -0
- package/lib/compileSchemaValidatorsCode.js +80 -0
- package/lib/compileSchemaValidatorsCode.js.map +1 -0
- package/lib/createAtaInstance.d.ts +27 -0
- package/lib/createAtaInstance.js +68 -0
- package/lib/createAtaInstance.js.map +1 -0
- package/lib/createPrecompiledValidator.d.ts +15 -0
- package/lib/createPrecompiledValidator.js +17 -0
- package/lib/createPrecompiledValidator.js.map +1 -0
- package/lib/customizeValidator.d.ts +8 -0
- package/lib/customizeValidator.js +9 -0
- package/lib/customizeValidator.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/precompiledValidator.d.ts +89 -0
- package/lib/precompiledValidator.js +107 -0
- package/lib/precompiledValidator.js.map +1 -0
- package/lib/processRawValidationErrors.d.ts +28 -0
- package/lib/processRawValidationErrors.js +137 -0
- package/lib/processRawValidationErrors.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types.d.ts +63 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/validator.d.ts +85 -0
- package/lib/validator.js +154 -0
- package/lib/validator.js.map +1 -0
- package/package.json +113 -0
- package/src/compileSchemaValidators.ts +30 -0
- package/src/compileSchemaValidatorsCode.ts +92 -0
- package/src/createAtaInstance.ts +81 -0
- package/src/createPrecompiledValidator.ts +29 -0
- package/src/customizeValidator.ts +16 -0
- package/src/index.ts +8 -0
- package/src/precompiledValidator.ts +188 -0
- package/src/processRawValidationErrors.ts +197 -0
- package/src/tsconfig.json +15 -0
- package/src/types.ts +71 -0
- package/src/validator.ts +231 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
// src/precompiledValidator.ts
|
|
2
|
+
import {
|
|
3
|
+
deepEquals,
|
|
4
|
+
hashForSchema,
|
|
5
|
+
ID_KEY,
|
|
6
|
+
JUNK_OPTION_ID,
|
|
7
|
+
retrieveSchema
|
|
8
|
+
} from "@rjsf/utils";
|
|
9
|
+
import get2 from "lodash/get";
|
|
10
|
+
|
|
11
|
+
// src/processRawValidationErrors.ts
|
|
12
|
+
import {
|
|
13
|
+
ANY_OF_KEY,
|
|
14
|
+
createErrorHandler,
|
|
15
|
+
getDefaultFormState,
|
|
16
|
+
getUiOptions,
|
|
17
|
+
ONE_OF_KEY,
|
|
18
|
+
PROPERTIES_KEY,
|
|
19
|
+
toErrorSchema,
|
|
20
|
+
unwrapErrorHandler,
|
|
21
|
+
validationDataMerge
|
|
22
|
+
} from "@rjsf/utils";
|
|
23
|
+
import get from "lodash/get";
|
|
24
|
+
function filterDuplicateErrors(errorList, suppressDuplicateFiltering = "none") {
|
|
25
|
+
if (suppressDuplicateFiltering === "all") {
|
|
26
|
+
return errorList;
|
|
27
|
+
}
|
|
28
|
+
return errorList.reduce((acc, err) => {
|
|
29
|
+
const { message, schemaPath } = err;
|
|
30
|
+
const anyOfIndex = suppressDuplicateFiltering !== "anyOf" ? schemaPath?.indexOf(`/${ANY_OF_KEY}/`) : void 0;
|
|
31
|
+
const oneOfIndex = suppressDuplicateFiltering !== "oneOf" ? schemaPath?.indexOf(`/${ONE_OF_KEY}/`) : void 0;
|
|
32
|
+
let schemaPrefix;
|
|
33
|
+
if (anyOfIndex && anyOfIndex >= 0) {
|
|
34
|
+
schemaPrefix = schemaPath?.substring(0, anyOfIndex);
|
|
35
|
+
} else if (oneOfIndex && oneOfIndex >= 0) {
|
|
36
|
+
schemaPrefix = schemaPath?.substring(0, oneOfIndex);
|
|
37
|
+
}
|
|
38
|
+
const dup = schemaPrefix ? acc.find((e) => e.message === message && e.schemaPath?.startsWith(schemaPrefix)) : void 0;
|
|
39
|
+
if (!dup) {
|
|
40
|
+
acc.push(err);
|
|
41
|
+
}
|
|
42
|
+
return acc;
|
|
43
|
+
}, []);
|
|
44
|
+
}
|
|
45
|
+
function transformRJSFValidationErrors(errors = [], uiSchema, suppressDuplicateFiltering) {
|
|
46
|
+
const errorList = errors.map((e) => {
|
|
47
|
+
const { instancePath, keyword, params, schemaPath, parentSchema } = e;
|
|
48
|
+
let { message = "" } = e;
|
|
49
|
+
let property = instancePath.replace(/\//g, ".");
|
|
50
|
+
let stack = `${property} ${message}`.trim();
|
|
51
|
+
let uiTitle = "";
|
|
52
|
+
const p = params;
|
|
53
|
+
const rawPropertyNames = [
|
|
54
|
+
...p?.deps?.split(", ") || [],
|
|
55
|
+
p?.missingProperty,
|
|
56
|
+
p?.property
|
|
57
|
+
].filter((item) => Boolean(item));
|
|
58
|
+
if (rawPropertyNames.length > 0) {
|
|
59
|
+
rawPropertyNames.forEach((currentProperty) => {
|
|
60
|
+
const path = property ? `${property}.${currentProperty}` : currentProperty;
|
|
61
|
+
let uiSchemaTitle = getUiOptions(get(uiSchema, `${path.replace(/^\./, "")}`)).title;
|
|
62
|
+
if (uiSchemaTitle === void 0) {
|
|
63
|
+
const uiSchemaPath = schemaPath.replace(/\/properties\//g, "/").split("/").slice(1, -1).concat([currentProperty]);
|
|
64
|
+
uiSchemaTitle = getUiOptions(get(uiSchema, uiSchemaPath)).title;
|
|
65
|
+
}
|
|
66
|
+
if (uiSchemaTitle) {
|
|
67
|
+
message = message.replace(`'${currentProperty}'`, `'${uiSchemaTitle}'`);
|
|
68
|
+
uiTitle = uiSchemaTitle;
|
|
69
|
+
} else {
|
|
70
|
+
const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, "title"]);
|
|
71
|
+
if (parentSchemaTitle) {
|
|
72
|
+
message = message.replace(`'${currentProperty}'`, `'${parentSchemaTitle}'`);
|
|
73
|
+
uiTitle = parentSchemaTitle;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
stack = message;
|
|
78
|
+
} else {
|
|
79
|
+
const uiSchemaTitle = getUiOptions(get(uiSchema, `${property.replace(/^\./, "")}`)).title;
|
|
80
|
+
if (uiSchemaTitle) {
|
|
81
|
+
stack = `'${uiSchemaTitle}' ${message}`.trim();
|
|
82
|
+
uiTitle = uiSchemaTitle;
|
|
83
|
+
} else {
|
|
84
|
+
const parentSchemaTitle = parentSchema?.title;
|
|
85
|
+
if (parentSchemaTitle) {
|
|
86
|
+
stack = `'${parentSchemaTitle}' ${message}`.trim();
|
|
87
|
+
uiTitle = parentSchemaTitle;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (p && "missingProperty" in p) {
|
|
92
|
+
property = property ? `${property}.${p.missingProperty}` : p.missingProperty;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
name: keyword,
|
|
96
|
+
property,
|
|
97
|
+
message,
|
|
98
|
+
params,
|
|
99
|
+
stack,
|
|
100
|
+
schemaPath,
|
|
101
|
+
title: uiTitle
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
return filterDuplicateErrors(errorList, suppressDuplicateFiltering);
|
|
105
|
+
}
|
|
106
|
+
function processRawValidationErrors(validator, rawErrors, formData, schema, customValidate, transformErrors, uiSchema, suppressDuplicateFiltering) {
|
|
107
|
+
const { validationError: invalidSchemaError } = rawErrors;
|
|
108
|
+
let errors = transformRJSFValidationErrors(rawErrors.errors, uiSchema, suppressDuplicateFiltering);
|
|
109
|
+
if (invalidSchemaError) {
|
|
110
|
+
errors = [...errors, { stack: invalidSchemaError.message }];
|
|
111
|
+
}
|
|
112
|
+
if (typeof transformErrors === "function") {
|
|
113
|
+
errors = transformErrors(errors, uiSchema);
|
|
114
|
+
}
|
|
115
|
+
let errorSchema = toErrorSchema(errors);
|
|
116
|
+
if (invalidSchemaError) {
|
|
117
|
+
errorSchema = {
|
|
118
|
+
...errorSchema,
|
|
119
|
+
$schema: {
|
|
120
|
+
__errors: [invalidSchemaError.message]
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (typeof customValidate !== "function") {
|
|
125
|
+
return { errors, errorSchema };
|
|
126
|
+
}
|
|
127
|
+
const newFormData = getDefaultFormState(validator, schema, formData, schema, true);
|
|
128
|
+
const errorHandler = customValidate(newFormData, createErrorHandler(newFormData), uiSchema, errorSchema);
|
|
129
|
+
const userErrorSchema = unwrapErrorHandler(errorHandler);
|
|
130
|
+
return validationDataMerge({ errors, errorSchema }, userErrorSchema);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/precompiledValidator.ts
|
|
134
|
+
var ATAPrecompiledValidator = class {
|
|
135
|
+
/** Constructs an `ATAPrecompiledValidator` instance using the `validateFns` and `rootSchema`
|
|
136
|
+
*
|
|
137
|
+
* @param validateFns - The map of the validation functions that are generated by the `schemaCompile()` function
|
|
138
|
+
* @param rootSchema - The root schema that was used with the `compileSchema()` function
|
|
139
|
+
* @param [localizer] - If provided, is used to localize a list of ata `ValidationError`s
|
|
140
|
+
* @param [suppressDuplicateFiltering] - Controls which duplicate filtering is suppressed; see `filterDuplicateErrors`
|
|
141
|
+
* @throws - Error when the base schema of the precompiled validator does not have a matching validator function
|
|
142
|
+
*/
|
|
143
|
+
constructor(validateFns, rootSchema, localizer, suppressDuplicateFiltering) {
|
|
144
|
+
this.rootSchema = rootSchema;
|
|
145
|
+
this.validateFns = validateFns;
|
|
146
|
+
this.localizer = localizer;
|
|
147
|
+
this.suppressDuplicateFiltering = suppressDuplicateFiltering;
|
|
148
|
+
this.mainValidator = this.getValidator(rootSchema);
|
|
149
|
+
}
|
|
150
|
+
/** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator
|
|
151
|
+
* functions.
|
|
152
|
+
*
|
|
153
|
+
* @param schema - The schema for which a precompiled validator function is desired
|
|
154
|
+
* @returns - The precompiled validator function associated with this schema
|
|
155
|
+
*/
|
|
156
|
+
getValidator(schema) {
|
|
157
|
+
const key = get2(schema, ID_KEY) || hashForSchema(schema);
|
|
158
|
+
const validator = this.validateFns[key];
|
|
159
|
+
if (!validator) {
|
|
160
|
+
throw new Error(`No precompiled validator function was found for the given schema for "${key}"`);
|
|
161
|
+
}
|
|
162
|
+
return validator;
|
|
163
|
+
}
|
|
164
|
+
/** Ensures that the validator is using the same schema as the root schema used to construct the precompiled
|
|
165
|
+
* validator. It first compares the given `schema` against the root schema and if they aren't the same, then it
|
|
166
|
+
* checks against the resolved root schema, on the chance that a resolved version of the root schema was passed in
|
|
167
|
+
* instead of the raw root schema.
|
|
168
|
+
*
|
|
169
|
+
* @param schema - The schema against which to validate the form data
|
|
170
|
+
* @param [formData] - The form data to validate if any
|
|
171
|
+
*/
|
|
172
|
+
ensureSameRootSchema(schema, formData) {
|
|
173
|
+
if (!deepEquals(schema, this.rootSchema)) {
|
|
174
|
+
const resolvedRootSchema = retrieveSchema(this, this.rootSchema, this.rootSchema, formData);
|
|
175
|
+
if (!deepEquals(schema, resolvedRootSchema)) {
|
|
176
|
+
throw new Error(
|
|
177
|
+
"The schema associated with the precompiled validator differs from the rootSchema provided for validation"
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
/** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use
|
|
184
|
+
* by the playground. Returns the `errors` from the validation
|
|
185
|
+
*
|
|
186
|
+
* @param schema - The schema against which to validate the form data
|
|
187
|
+
* @param [formData] - The form data to validate, if any
|
|
188
|
+
* @throws - Error when the schema provided does not match the base schema of the precompiled validator
|
|
189
|
+
*/
|
|
190
|
+
rawValidation(schema, formData) {
|
|
191
|
+
this.ensureSameRootSchema(schema, formData);
|
|
192
|
+
this.mainValidator(formData);
|
|
193
|
+
if (typeof this.localizer === "function") {
|
|
194
|
+
this.localizer(this.mainValidator.errors);
|
|
195
|
+
}
|
|
196
|
+
const errors = this.mainValidator.errors || void 0;
|
|
197
|
+
this.mainValidator.errors = null;
|
|
198
|
+
return { errors };
|
|
199
|
+
}
|
|
200
|
+
/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives
|
|
201
|
+
* the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also
|
|
202
|
+
* supports a `transformErrors` function that will take the raw ata validation errors, prior to custom validation and
|
|
203
|
+
* transform them in what ever way it chooses.
|
|
204
|
+
*
|
|
205
|
+
* @param formData - The form data to validate
|
|
206
|
+
* @param schema - The schema against which to validate the form data
|
|
207
|
+
* @param [customValidate] - An optional function that is used to perform custom validation
|
|
208
|
+
* @param [transformErrors] - An optional function that is used to transform errors after ata validation
|
|
209
|
+
* @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
|
|
210
|
+
*/
|
|
211
|
+
validateFormData(formData, schema, customValidate, transformErrors, uiSchema) {
|
|
212
|
+
const rawErrors = this.rawValidation(schema, formData);
|
|
213
|
+
return processRawValidationErrors(
|
|
214
|
+
this,
|
|
215
|
+
rawErrors,
|
|
216
|
+
formData,
|
|
217
|
+
schema,
|
|
218
|
+
customValidate,
|
|
219
|
+
transformErrors,
|
|
220
|
+
uiSchema,
|
|
221
|
+
this.suppressDuplicateFiltering
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
/** Validates data against a schema, returning true if the data is valid, or false otherwise. If the schema is
|
|
225
|
+
* invalid, then this function will return false.
|
|
226
|
+
*
|
|
227
|
+
* @param schema - The schema against which to validate the form data
|
|
228
|
+
* @param formData - The form data to validate
|
|
229
|
+
* @param rootSchema - The root schema used to provide $ref resolutions
|
|
230
|
+
* @returns - true if the formData validates against the schema, false otherwise
|
|
231
|
+
* @throws - Error when the schema provided does not match the base schema of the precompiled validator OR if there
|
|
232
|
+
* isn't a precompiled validator function associated with the schema
|
|
233
|
+
*/
|
|
234
|
+
isValid(schema, formData, rootSchema) {
|
|
235
|
+
this.ensureSameRootSchema(rootSchema, formData);
|
|
236
|
+
if (get2(schema, ID_KEY) === JUNK_OPTION_ID) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
const validator = this.getValidator(schema);
|
|
240
|
+
return validator(formData);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// src/createPrecompiledValidator.ts
|
|
245
|
+
function createPrecompiledValidator(validateFns, rootSchema, localizer, suppressDuplicateFiltering) {
|
|
246
|
+
return new ATAPrecompiledValidator(validateFns, rootSchema, localizer, suppressDuplicateFiltering);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/validator.ts
|
|
250
|
+
import {
|
|
251
|
+
deepEquals as deepEquals2,
|
|
252
|
+
hashForSchema as hashForSchema2,
|
|
253
|
+
ID_KEY as ID_KEY2,
|
|
254
|
+
ROOT_SCHEMA_PREFIX,
|
|
255
|
+
withIdRefPrefix
|
|
256
|
+
} from "@rjsf/utils";
|
|
257
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
258
|
+
|
|
259
|
+
// src/createAtaInstance.ts
|
|
260
|
+
import { Validator } from "ata-validator";
|
|
261
|
+
import isObject from "lodash/isObject";
|
|
262
|
+
var ATA_CONFIG = {
|
|
263
|
+
verbose: true
|
|
264
|
+
};
|
|
265
|
+
var COLOR_FORMAT_REGEX = /^(#?([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*\)))$/;
|
|
266
|
+
var DATA_URL_FORMAT_REGEX = /^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;
|
|
267
|
+
function asFormatChecker(spec) {
|
|
268
|
+
if (typeof spec === "function") {
|
|
269
|
+
return spec;
|
|
270
|
+
}
|
|
271
|
+
const re = spec instanceof RegExp ? spec : new RegExp(spec);
|
|
272
|
+
return (value) => re.test(value);
|
|
273
|
+
}
|
|
274
|
+
function createAtaInstance(schema, options = {}) {
|
|
275
|
+
const { customFormats, ataOptionsOverrides, additionalMetaSchemas, extenderFn } = options;
|
|
276
|
+
const formats = {
|
|
277
|
+
color: asFormatChecker(COLOR_FORMAT_REGEX),
|
|
278
|
+
"data-url": asFormatChecker(DATA_URL_FORMAT_REGEX)
|
|
279
|
+
};
|
|
280
|
+
if (isObject(customFormats)) {
|
|
281
|
+
for (const [name, spec] of Object.entries(customFormats)) {
|
|
282
|
+
formats[name] = asFormatChecker(spec);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const validatorOptions = {
|
|
286
|
+
...ATA_CONFIG,
|
|
287
|
+
...ataOptionsOverrides,
|
|
288
|
+
formats
|
|
289
|
+
};
|
|
290
|
+
let validator = new Validator(schema, validatorOptions);
|
|
291
|
+
if (Array.isArray(additionalMetaSchemas)) {
|
|
292
|
+
for (const meta of additionalMetaSchemas) {
|
|
293
|
+
validator.addSchema(meta);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (typeof extenderFn === "function") {
|
|
297
|
+
validator = extenderFn(validator);
|
|
298
|
+
}
|
|
299
|
+
return validator;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/validator.ts
|
|
303
|
+
var ATAValidator = class {
|
|
304
|
+
constructor(options, localizer) {
|
|
305
|
+
/** Per-schema-id cache of constructed ata `Validator` instances. AJV uses a
|
|
306
|
+
* single instance with a schema registry; ata is schema-bound, so we
|
|
307
|
+
* maintain the registry ourselves.
|
|
308
|
+
*/
|
|
309
|
+
this.validators = /* @__PURE__ */ new Map();
|
|
310
|
+
/** True once a `rootSchema` has been registered in this lifecycle. */
|
|
311
|
+
this.hasRegisteredRootSchema = false;
|
|
312
|
+
this.options = options;
|
|
313
|
+
this.localizer = localizer;
|
|
314
|
+
this.suppressDuplicateFiltering = options.suppressDuplicateFiltering;
|
|
315
|
+
}
|
|
316
|
+
/** Resets the cached validators and root-schema bookkeeping. Mirrors
|
|
317
|
+
* `AJV8Validator#reset` so RJSF's test harness can flush state between runs.
|
|
318
|
+
*/
|
|
319
|
+
reset() {
|
|
320
|
+
this.validators.clear();
|
|
321
|
+
this.lastSeenRootSchema = void 0;
|
|
322
|
+
this.hasRegisteredRootSchema = false;
|
|
323
|
+
}
|
|
324
|
+
/** Returns a structural copy of `formData` so ata's default-applier
|
|
325
|
+
* (which writes `default` values into the input object during validation)
|
|
326
|
+
* doesn't leak a mutation back to the caller. RJSF probes the same data
|
|
327
|
+
* through `isValid` repeatedly while resolving oneOf/anyOf options, and
|
|
328
|
+
* a mutated probe changes subsequent answers, so the wrapper has to
|
|
329
|
+
* preserve referential purity that AJV provides by default.
|
|
330
|
+
*/
|
|
331
|
+
cloneForValidation(data) {
|
|
332
|
+
if (data === null || typeof data !== "object") {
|
|
333
|
+
return data;
|
|
334
|
+
}
|
|
335
|
+
if (typeof globalThis.structuredClone === "function") {
|
|
336
|
+
return globalThis.structuredClone(data);
|
|
337
|
+
}
|
|
338
|
+
return cloneDeep(data);
|
|
339
|
+
}
|
|
340
|
+
/** Returns the cached ata `Validator` for the given id, or builds and
|
|
341
|
+
* caches a new one. When a rootSchema has been registered via
|
|
342
|
+
* `handleSchemaUpdate`, it is supplied as a sibling schema so `$ref` to
|
|
343
|
+
* the root resolves regardless of which sub-schema is being validated.
|
|
344
|
+
*/
|
|
345
|
+
getOrBuild(id, schema) {
|
|
346
|
+
const existing = this.validators.get(id);
|
|
347
|
+
if (existing && deepEquals2(existing.schema, schema)) {
|
|
348
|
+
return existing.validator;
|
|
349
|
+
}
|
|
350
|
+
const siblingRoots = this.cachedRootSchema && this.cachedRootSchema !== schema ? [this.cachedRootSchema] : [];
|
|
351
|
+
const optionsWithSchemas = {
|
|
352
|
+
...this.options,
|
|
353
|
+
ataOptionsOverrides: {
|
|
354
|
+
...this.options.ataOptionsOverrides || {},
|
|
355
|
+
...siblingRoots.length ? { schemas: siblingRoots } : {}
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const validator = createAtaInstance(schema, optionsWithSchemas);
|
|
359
|
+
this.validators.set(id, { validator, schema });
|
|
360
|
+
return validator;
|
|
361
|
+
}
|
|
362
|
+
/** Runs raw validation against the given schema. Equivalent to
|
|
363
|
+
* `AJV8Validator#rawValidation`: returns ata's error array (already in
|
|
364
|
+
* AJV-compatible shape) plus any compilation error encountered.
|
|
365
|
+
*/
|
|
366
|
+
rawValidation(schema, formData) {
|
|
367
|
+
let compilationError;
|
|
368
|
+
let errors;
|
|
369
|
+
try {
|
|
370
|
+
const id = schema[ID_KEY2] ?? hashForSchema2(schema);
|
|
371
|
+
const validator = this.getOrBuild(id, schema);
|
|
372
|
+
const result = validator.validate(this.cloneForValidation(formData));
|
|
373
|
+
errors = result.valid ? void 0 : result.errors;
|
|
374
|
+
if (errors && typeof this.localizer === "function") {
|
|
375
|
+
this.localizer(errors);
|
|
376
|
+
}
|
|
377
|
+
} catch (err) {
|
|
378
|
+
compilationError = err;
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
errors,
|
|
382
|
+
validationError: compilationError
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
/** Validates `formData` and returns RJSF's `ValidationData<T>`. See
|
|
386
|
+
* `processRawValidationErrors` for the shape of the post-processing
|
|
387
|
+
* pipeline (custom validation, transform hook, ui-title resolution).
|
|
388
|
+
*/
|
|
389
|
+
validateFormData(formData, schema, customValidate, transformErrors, uiSchema) {
|
|
390
|
+
const rawErrors = this.rawValidation(schema, formData);
|
|
391
|
+
return processRawValidationErrors(
|
|
392
|
+
this,
|
|
393
|
+
rawErrors,
|
|
394
|
+
formData,
|
|
395
|
+
schema,
|
|
396
|
+
customValidate,
|
|
397
|
+
transformErrors,
|
|
398
|
+
uiSchema,
|
|
399
|
+
this.suppressDuplicateFiltering
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
/** Registers (or refreshes) the rootSchema in the per-schema registry so
|
|
403
|
+
* subsequent `$ref`-resolving validators can see it. Mirrors AJV's
|
|
404
|
+
* `addSchema(rootSchema, rootSchemaId)` flow.
|
|
405
|
+
*/
|
|
406
|
+
handleSchemaUpdate(rootSchema) {
|
|
407
|
+
if (this.lastSeenRootSchema === rootSchema && this.hasRegisteredRootSchema) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
const rootSchemaId = rootSchema[ID_KEY2] ?? ROOT_SCHEMA_PREFIX;
|
|
411
|
+
const rootWithId = rootSchema[ID_KEY2] === rootSchemaId ? rootSchema : { ...rootSchema, [ID_KEY2]: rootSchemaId };
|
|
412
|
+
this.cachedRootSchema = rootWithId;
|
|
413
|
+
const cached = this.validators.get(rootSchemaId);
|
|
414
|
+
if (!cached || !deepEquals2(cached.schema, rootWithId)) {
|
|
415
|
+
this.getOrBuild(rootSchemaId, rootWithId);
|
|
416
|
+
}
|
|
417
|
+
this.lastSeenRootSchema = rootSchema;
|
|
418
|
+
this.hasRegisteredRootSchema = true;
|
|
419
|
+
}
|
|
420
|
+
/** Boolean validation entrypoint. Returns false on validation failure or
|
|
421
|
+
* compilation error. Mirrors `AJV8Validator#isValid` semantics.
|
|
422
|
+
*/
|
|
423
|
+
isValid(schema, formData, rootSchema) {
|
|
424
|
+
try {
|
|
425
|
+
this.handleSchemaUpdate(rootSchema);
|
|
426
|
+
const schemaWithIdRefPrefix = withIdRefPrefix(schema);
|
|
427
|
+
const id = schemaWithIdRefPrefix[ID_KEY2] ?? hashForSchema2(schemaWithIdRefPrefix);
|
|
428
|
+
const validator = this.getOrBuild(id, schemaWithIdRefPrefix);
|
|
429
|
+
return validator.validate(this.cloneForValidation(formData)).valid;
|
|
430
|
+
} catch (e) {
|
|
431
|
+
console.warn("Error encountered compiling schema:", e);
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
// src/customizeValidator.ts
|
|
438
|
+
function customizeValidator(options = {}, localizer) {
|
|
439
|
+
return new ATAValidator(options, localizer);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// src/index.ts
|
|
443
|
+
var index_default = customizeValidator();
|
|
444
|
+
export {
|
|
445
|
+
ATAValidator,
|
|
446
|
+
createPrecompiledValidator,
|
|
447
|
+
customizeValidator,
|
|
448
|
+
index_default as default
|
|
449
|
+
};
|
|
450
|
+
//# sourceMappingURL=validator-ata.esm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/precompiledValidator.ts", "../src/processRawValidationErrors.ts", "../src/createPrecompiledValidator.ts", "../src/validator.ts", "../src/createAtaInstance.ts", "../src/customizeValidator.ts", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n CustomValidator,\n deepEquals,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n JUNK_OPTION_ID,\n retrieveSchema,\n RJSFSchema,\n StrictRJSFSchema,\n UiSchema,\n ValidationData,\n ValidatorType,\n} from '@rjsf/utils';\nimport type { ValidationError } from 'ata-validator';\nimport get from 'lodash/get';\n\nimport processRawValidationErrors, { RawValidationErrorsType } from './processRawValidationErrors';\nimport { CompiledValidateFunction, Localizer, SuppressDuplicateFilteringType, ValidatorFunctions } from './types';\n\n/** `ValidatorType` implementation that uses an ata precompiled validator as created by the\n * `compileSchemaValidators()` function provided by the `@rjsf/validator-ata` library.\n */\nexport default class ATAPrecompiledValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n> implements ValidatorType<T, S, F> {\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 ata errors\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Controls which duplicate error filtering is suppressed; see `filterDuplicateErrors`\n *\n * @private\n */\n readonly suppressDuplicateFiltering?: SuppressDuplicateFilteringType;\n\n /** Constructs an `ATAPrecompiledValidator` 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 ata `ValidationError`s\n * @param [suppressDuplicateFiltering] - Controls which duplicate filtering is suppressed; see `filterDuplicateErrors`\n * @throws - Error when the base schema of the precompiled validator does not have a matching validator function\n */\n constructor(\n validateFns: ValidatorFunctions,\n rootSchema: S,\n localizer?: Localizer,\n suppressDuplicateFiltering?: SuppressDuplicateFilteringType,\n ) {\n this.rootSchema = rootSchema;\n this.validateFns = validateFns;\n this.localizer = localizer;\n this.suppressDuplicateFiltering = suppressDuplicateFiltering;\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 /** Ensures that the validator is using the same schema as the root schema used to construct the precompiled\n * validator. It first compares the given `schema` against the root schema and if they aren't the same, then it\n * checks against the resolved root schema, on the chance that a resolved version of the root schema was passed in\n * instead of the raw root schema.\n *\n * @param schema - The schema against which to validate the form data\n * @param [formData] - The form data to validate if any\n */\n ensureSameRootSchema(schema: S, formData?: T) {\n if (!deepEquals(schema, this.rootSchema)) {\n // Resolve the root schema with the passed in form data since that may affect the resolution\n const resolvedRootSchema = retrieveSchema(this, this.rootSchema, this.rootSchema, formData);\n if (!deepEquals(schema, resolvedRootSchema)) {\n throw new Error(\n 'The schema associated with the precompiled validator differs from the rootSchema provided for validation',\n );\n }\n }\n return true;\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\n * @param [formData] - The form data to validate, if any\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 this.ensureSameRootSchema(schema, formData);\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 ata 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 ata 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<ValidationError>(schema, formData);\n return processRawValidationErrors(\n this,\n rawErrors,\n formData,\n schema,\n customValidate,\n transformErrors,\n uiSchema,\n this.suppressDuplicateFiltering,\n );\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 this.ensureSameRootSchema(rootSchema, formData);\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 {\n ANY_OF_KEY,\n createErrorHandler,\n CustomValidator,\n ErrorTransformer,\n FormContextType,\n getDefaultFormState,\n getUiOptions,\n ONE_OF_KEY,\n PROPERTIES_KEY,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n toErrorSchema,\n UiSchema,\n unwrapErrorHandler,\n validationDataMerge,\n ValidatorType,\n} from '@rjsf/utils';\nimport type { ValidationError } from 'ata-validator';\nimport get from 'lodash/get';\n\nimport type { SuppressDuplicateFilteringType } from './types';\n\nexport type RawValidationErrorsType<Result = any> = {\n errors?: Result[];\n validationError?: Error;\n};\n\n/** Filters duplicate errors from `anyOf`/`oneOf` schema paths according to\n * the `suppressDuplicateFiltering` flag. Mirrors the `@rjsf/validator-ajv8`\n * implementation: under any non-`'all'` setting, duplicate messages that\n * share a common prefix before the `/anyOf/` or `/oneOf/` segment are\n * collapsed into a single entry.\n */\nexport function filterDuplicateErrors(\n errorList: RJSFValidationError[],\n suppressDuplicateFiltering: SuppressDuplicateFilteringType = 'none',\n): RJSFValidationError[] {\n if (suppressDuplicateFiltering === 'all') {\n return errorList;\n }\n return errorList.reduce((acc: RJSFValidationError[], err: RJSFValidationError) => {\n const { message, schemaPath } = err;\n const anyOfIndex = suppressDuplicateFiltering !== 'anyOf' ? schemaPath?.indexOf(`/${ANY_OF_KEY}/`) : undefined;\n const oneOfIndex = suppressDuplicateFiltering !== 'oneOf' ? schemaPath?.indexOf(`/${ONE_OF_KEY}/`) : undefined;\n let schemaPrefix: string | undefined;\n if (anyOfIndex && anyOfIndex >= 0) {\n schemaPrefix = schemaPath?.substring(0, anyOfIndex);\n } else if (oneOfIndex && oneOfIndex >= 0) {\n schemaPrefix = schemaPath?.substring(0, oneOfIndex);\n }\n const dup = schemaPrefix\n ? acc.find((e: RJSFValidationError) => e.message === message && e.schemaPath?.startsWith(schemaPrefix))\n : undefined;\n if (!dup) {\n acc.push(err);\n }\n return acc;\n }, [] as RJSFValidationError[]);\n}\n\n/** Transforms ata-validator errors into the RJSF-internal `RJSFValidationError`\n * shape. ata's error objects already use the same field names AJV does\n * (`instancePath`, `keyword`, `params`, `schemaPath`, `parentSchema`,\n * `message`), so the conversion is structural only.\n */\nexport function transformRJSFValidationErrors<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n errors: ValidationError[] = [],\n uiSchema?: UiSchema<T, S, F>,\n suppressDuplicateFiltering?: SuppressDuplicateFilteringType,\n): RJSFValidationError[] {\n const errorList = errors.map((e: ValidationError) => {\n const { instancePath, keyword, params, schemaPath, parentSchema } = e;\n let { message = '' } = e;\n let property = instancePath.replace(/\\//g, '.');\n let stack = `${property} ${message}`.trim();\n let uiTitle = '';\n\n const p = params as Record<string, any>;\n const rawPropertyNames: string[] = [\n ...((p?.deps as string | undefined)?.split(', ') || []),\n p?.missingProperty,\n p?.property,\n ].filter((item) => Boolean(item));\n\n if (rawPropertyNames.length > 0) {\n rawPropertyNames.forEach((currentProperty) => {\n const path = property ? `${property}.${currentProperty}` : currentProperty;\n let uiSchemaTitle = getUiOptions(get(uiSchema, `${path.replace(/^\\./, '')}`)).title;\n if (uiSchemaTitle === undefined) {\n const uiSchemaPath = schemaPath\n .replace(/\\/properties\\//g, '/')\n .split('/')\n .slice(1, -1)\n .concat([currentProperty]);\n uiSchemaTitle = getUiOptions(get(uiSchema, uiSchemaPath)).title;\n }\n if (uiSchemaTitle) {\n message = message.replace(`'${currentProperty}'`, `'${uiSchemaTitle}'`);\n uiTitle = uiSchemaTitle;\n } else {\n const parentSchemaTitle = get(parentSchema, [PROPERTIES_KEY, currentProperty, 'title']);\n if (parentSchemaTitle) {\n message = message.replace(`'${currentProperty}'`, `'${parentSchemaTitle}'`);\n uiTitle = parentSchemaTitle;\n }\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 uiTitle = uiSchemaTitle;\n } else {\n const parentSchemaTitle = (parentSchema as { title?: string } | undefined)?.title;\n\n if (parentSchemaTitle) {\n stack = `'${parentSchemaTitle}' ${message}`.trim();\n uiTitle = parentSchemaTitle;\n }\n }\n }\n\n if (p && 'missingProperty' in p) {\n property = property ? `${property}.${p.missingProperty}` : p.missingProperty;\n }\n\n return {\n name: keyword,\n property,\n message,\n params,\n stack,\n schemaPath,\n title: uiTitle,\n };\n });\n return filterDuplicateErrors(errorList, suppressDuplicateFiltering);\n}\n\n/** Processes raw ata validation errors into the `ValidationData<T>` shape\n * RJSF consumes. Mirrors the AJV-validator's `processRawValidationErrors`,\n * including the optional `customValidate` and `transformErrors` hooks.\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<ValidationError>,\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 suppressDuplicateFiltering?: SuppressDuplicateFilteringType,\n) {\n const { validationError: invalidSchemaError } = rawErrors;\n let errors = transformRJSFValidationErrors<T, S, F>(rawErrors.errors, uiSchema, suppressDuplicateFiltering);\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 const newFormData = getDefaultFormState<T, S, F>(validator, schema, formData, schema, true) as T;\n\n const errorHandler = customValidate(newFormData, createErrorHandler<T>(newFormData), uiSchema, errorSchema);\n const userErrorSchema = unwrapErrorHandler<T>(errorHandler);\n return validationDataMerge<T>({ errors, errorSchema }, userErrorSchema);\n}\n", "import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';\n\nimport ATAPrecompiledValidator from './precompiledValidator';\nimport { Localizer, SuppressDuplicateFilteringType, ValidatorFunctions } from './types';\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 ata 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 ata `ValidationError`s\n * @param [suppressDuplicateFiltering] - Controls which duplicate filtering is suppressed; see `filterDuplicateErrors`\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>(\n validateFns: ValidatorFunctions,\n rootSchema: S,\n localizer?: Localizer,\n suppressDuplicateFiltering?: SuppressDuplicateFilteringType,\n): ValidatorType<T, S, F> {\n return new ATAPrecompiledValidator<T, S, F>(validateFns, rootSchema, localizer, suppressDuplicateFiltering);\n}\n", "import {\n CustomValidator,\n deepEquals,\n ErrorTransformer,\n FormContextType,\n hashForSchema,\n ID_KEY,\n RJSFSchema,\n ROOT_SCHEMA_PREFIX,\n StrictRJSFSchema,\n UiSchema,\n ValidationData,\n ValidatorType,\n withIdRefPrefix,\n} from '@rjsf/utils';\nimport type { ValidationError, Validator } from 'ata-validator';\nimport cloneDeep from 'lodash/cloneDeep';\n\nimport createAtaInstance from './createAtaInstance';\nimport processRawValidationErrors, { type RawValidationErrorsType } from './processRawValidationErrors';\nimport type { CustomValidatorOptionsType, Localizer, SuppressDuplicateFilteringType } from './types';\n\n/** `ValidatorType` implementation backed by `ata-validator`.\n *\n * ata is schema-bound (one `Validator` per schema) rather than instance-with-\n * registry like AJV, so this class maintains its own per-schema-id cache and\n * registers cross-schema dependencies through ata's `addSchema` so `$ref`\n * still resolves between schemas RJSF passes in.\n */\nexport default class ATAValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n> implements ValidatorType<T, S, F> {\n /** Stable copy of the constructor options, used when (re)building per-schema\n * `Validator` instances on demand.\n *\n * @private\n */\n readonly options: CustomValidatorOptionsType;\n\n /** The Localizer function applied to ata errors before they are returned.\n *\n * @private\n */\n readonly localizer?: Localizer;\n\n /** Controls which duplicate error filtering is suppressed; see\n * `processRawValidationErrors#filterDuplicateErrors`.\n *\n * @private\n */\n readonly suppressDuplicateFiltering?: SuppressDuplicateFilteringType;\n\n /** Per-schema-id cache of constructed ata `Validator` instances. AJV uses a\n * single instance with a schema registry; ata is schema-bound, so we\n * maintain the registry ourselves.\n */\n private readonly validators = new Map<string, { validator: Validator; schema: object }>();\n\n /** Most recent `rootSchema` reference seen by `handleSchemaUpdate`, used as\n * a fast-path to skip a deep-equality check when the same root is passed\n * back-to-back.\n */\n private lastSeenRootSchema?: S;\n\n /** True once a `rootSchema` has been registered in this lifecycle. */\n private hasRegisteredRootSchema = false;\n\n constructor(options: CustomValidatorOptionsType, localizer?: Localizer) {\n this.options = options;\n this.localizer = localizer;\n this.suppressDuplicateFiltering = options.suppressDuplicateFiltering;\n }\n\n /** Resets the cached validators and root-schema bookkeeping. Mirrors\n * `AJV8Validator#reset` so RJSF's test harness can flush state between runs.\n */\n reset() {\n this.validators.clear();\n this.lastSeenRootSchema = undefined;\n this.hasRegisteredRootSchema = false;\n }\n\n /** The most recently registered rootSchema, kept so we can pass it to ata's\n * `schemas` constructor option when building validators for sub-schemas.\n * This is how `$ref` to root-level definitions resolves under ata's\n * per-schema model (vs AJV's single-instance registry).\n */\n private cachedRootSchema?: object;\n\n /** Returns a structural copy of `formData` so ata's default-applier\n * (which writes `default` values into the input object during validation)\n * doesn't leak a mutation back to the caller. RJSF probes the same data\n * through `isValid` repeatedly while resolving oneOf/anyOf options, and\n * a mutated probe changes subsequent answers, so the wrapper has to\n * preserve referential purity that AJV provides by default.\n */\n private cloneForValidation<D>(data: D): D {\n if (data === null || typeof data !== 'object') {\n return data;\n }\n if (typeof globalThis.structuredClone === 'function') {\n return globalThis.structuredClone(data);\n }\n return cloneDeep(data);\n }\n\n /** Returns the cached ata `Validator` for the given id, or builds and\n * caches a new one. When a rootSchema has been registered via\n * `handleSchemaUpdate`, it is supplied as a sibling schema so `$ref` to\n * the root resolves regardless of which sub-schema is being validated.\n */\n private getOrBuild(id: string, schema: object): Validator {\n const existing = this.validators.get(id);\n if (existing && deepEquals(existing.schema, schema)) {\n return existing.validator;\n }\n // Pass the rootSchema as a sibling so `$ref` to its definitions resolves.\n // Skip when the schema itself is the root, otherwise ata sees a\n // self-referential addition.\n const siblingRoots = this.cachedRootSchema && this.cachedRootSchema !== schema ? [this.cachedRootSchema] : [];\n const optionsWithSchemas = {\n ...this.options,\n ataOptionsOverrides: {\n ...(this.options.ataOptionsOverrides || {}),\n ...(siblingRoots.length ? { schemas: siblingRoots } : {}),\n },\n };\n const validator = createAtaInstance(schema, optionsWithSchemas);\n this.validators.set(id, { validator, schema });\n return validator;\n }\n\n /** Runs raw validation against the given schema. Equivalent to\n * `AJV8Validator#rawValidation`: returns ata's error array (already in\n * AJV-compatible shape) plus any compilation error encountered.\n */\n rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {\n let compilationError: Error | undefined;\n let errors: ValidationError[] | undefined;\n\n try {\n const id = (schema[ID_KEY] as string | undefined) ?? hashForSchema(schema);\n const validator = this.getOrBuild(id, schema);\n const result = validator.validate(this.cloneForValidation(formData));\n errors = result.valid ? undefined : result.errors;\n\n if (errors && typeof this.localizer === 'function') {\n // ata freezes `error.params`, so the AJV-validator's pre-quote dance\n // (used to coax `ajv-i18n` into producing quoted property names)\n // can't be applied verbatim. The hook is invoked with the raw\n // ata errors; localizers that mutate `message` in place still work.\n this.localizer(errors);\n }\n } catch (err) {\n compilationError = err as Error;\n }\n\n return {\n errors: errors as unknown as Result[] | undefined,\n validationError: compilationError,\n };\n }\n\n /** Validates `formData` and returns RJSF's `ValidationData<T>`. See\n * `processRawValidationErrors` for the shape of the post-processing\n * pipeline (custom validation, transform hook, ui-title resolution).\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<ValidationError>(schema, formData);\n return processRawValidationErrors(\n this,\n rawErrors,\n formData,\n schema,\n customValidate,\n transformErrors,\n uiSchema,\n this.suppressDuplicateFiltering,\n );\n }\n\n /** Registers (or refreshes) the rootSchema in the per-schema registry so\n * subsequent `$ref`-resolving validators can see it. Mirrors AJV's\n * `addSchema(rootSchema, rootSchemaId)` flow.\n */\n handleSchemaUpdate(rootSchema: S): void {\n if (this.lastSeenRootSchema === rootSchema && this.hasRegisteredRootSchema) {\n return;\n }\n const rootSchemaId = (rootSchema[ID_KEY] as string | undefined) ?? ROOT_SCHEMA_PREFIX;\n // Inject $id into a copy of the rootSchema so ata's schema registry can\n // resolve `<rootSchemaId>#/...` refs produced by `withIdRefPrefix`.\n // The original user-supplied schema is left untouched.\n const rootWithId =\n rootSchema[ID_KEY] === rootSchemaId\n ? (rootSchema as object)\n : { ...(rootSchema as object), [ID_KEY]: rootSchemaId };\n this.cachedRootSchema = rootWithId;\n const cached = this.validators.get(rootSchemaId);\n if (!cached || !deepEquals(cached.schema, rootWithId)) {\n this.getOrBuild(rootSchemaId, rootWithId);\n }\n this.lastSeenRootSchema = rootSchema;\n this.hasRegisteredRootSchema = true;\n }\n\n /** Boolean validation entrypoint. Returns false on validation failure or\n * compilation error. Mirrors `AJV8Validator#isValid` semantics.\n */\n isValid(schema: S, formData: T | undefined, rootSchema: S) {\n try {\n this.handleSchemaUpdate(rootSchema);\n const schemaWithIdRefPrefix = withIdRefPrefix<S>(schema) as S;\n const id = (schemaWithIdRefPrefix[ID_KEY] as string | undefined) ?? hashForSchema(schemaWithIdRefPrefix);\n const validator = this.getOrBuild(id, schemaWithIdRefPrefix);\n return validator.validate(this.cloneForValidation(formData)).valid;\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn('Error encountered compiling schema:', e);\n return false;\n }\n }\n}\n", "import { Validator, type ValidatorOptions } from 'ata-validator';\nimport isObject from 'lodash/isObject';\n\nimport type { AtaFormatChecker, CustomValidatorOptionsType } from './types';\n\n/** Default options applied to every ata `Validator` constructed for RJSF.\n * `verbose: true` keeps `parentSchema` available on errors, which the RJSF\n * error transformer uses to recover field titles. The remainder match\n * `@rjsf/validator-ajv8`'s defaults (`allErrors`-equivalent behavior is\n * ata's default).\n */\nexport const ATA_CONFIG: ValidatorOptions = {\n verbose: true,\n} as const;\n\n/** Color names + hex + `rgb()` regex source. Mirrors the pattern shipped by\n * `@rjsf/validator-ajv8` so RJSF schemas using `format: 'color'` keep\n * working when swapped to validator-ata.\n */\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*\\)))$/;\n\n/** RFC 2397 data URL with required mime type and base64 marker, matching\n * the shape used by `@rjsf/validator-ajv8`.\n */\nexport const DATA_URL_FORMAT_REGEX = /^data:([a-z]+\\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;\n\n/** Coerces the user-supplied custom format value into the `(value: string)\n * => boolean` shape expected by ata. Strings are treated as RegExp source\n * (anchored at both ends if not already), RegExps are converted to a `.test`\n * call, functions pass through.\n */\nfunction asFormatChecker(spec: string | RegExp | AtaFormatChecker): AtaFormatChecker {\n if (typeof spec === 'function') {\n return spec;\n }\n const re = spec instanceof RegExp ? spec : new RegExp(spec);\n return (value: string) => re.test(value);\n}\n\n/** Builds a fresh `ata-validator` `Validator` for a given schema with all\n * RJSF-aware defaults and user customizations applied.\n *\n * The factory exists so that the validator class can construct one\n * `Validator` per schema-id (ata is schema-bound, unlike AJV's single\n * instance with a schema registry) while keeping the option translation\n * in one place.\n */\nexport default function createAtaInstance(schema: object, options: CustomValidatorOptionsType = {}): Validator {\n const { customFormats, ataOptionsOverrides, additionalMetaSchemas, extenderFn } = options;\n\n const formats: Record<string, AtaFormatChecker> = {\n color: asFormatChecker(COLOR_FORMAT_REGEX),\n 'data-url': asFormatChecker(DATA_URL_FORMAT_REGEX),\n };\n if (isObject(customFormats)) {\n for (const [name, spec] of Object.entries(customFormats!)) {\n formats[name] = asFormatChecker(spec);\n }\n }\n\n const validatorOptions: ValidatorOptions = {\n ...ATA_CONFIG,\n ...ataOptionsOverrides,\n formats,\n };\n\n let validator = new Validator(schema, validatorOptions);\n\n if (Array.isArray(additionalMetaSchemas)) {\n for (const meta of additionalMetaSchemas) {\n validator.addSchema(meta);\n }\n }\n\n if (typeof extenderFn === 'function') {\n validator = extenderFn(validator);\n }\n\n return validator;\n}\n", "import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\n\nimport type { CustomValidatorOptionsType, Localizer } from './types';\nimport ATAValidator from './validator';\n\n/** Build an `ATAValidator` instance, optionally customized with format\n * checkers, validator overrides, an extender hook, or a localizer. Mirrors\n * `@rjsf/validator-ajv8`'s `customizeValidator`.\n */\nexport default function customizeValidator<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(options: CustomValidatorOptionsType = {}, localizer?: Localizer) {\n return new ATAValidator<T, S, F>(options, localizer);\n}\n", "import createPrecompiledValidator from './createPrecompiledValidator';\nimport customizeValidator from './customizeValidator';\n\nexport { customizeValidator, createPrecompiledValidator };\nexport { default as ATAValidator } from './validator';\nexport * from './types';\n\nexport default customizeValidator();\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EAEE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAEP,OAAOA,UAAS;;;AChBhB;AAAA,EACE;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EAEA;AAAA,EACA;AAAA,OAEK;AAEP,OAAO,SAAS;AAeT,SAAS,sBACd,WACA,6BAA6D,QACtC;AACvB,MAAI,+BAA+B,OAAO;AACxC,WAAO;AAAA,EACT;AACA,SAAO,UAAU,OAAO,CAAC,KAA4B,QAA6B;AAChF,UAAM,EAAE,SAAS,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