@orion-js/schema 4.0.0-next.4 → 4.0.0-next.6

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 CHANGED
@@ -49,8 +49,47 @@ __export(index_exports, {
49
49
  });
50
50
  module.exports = __toCommonJS(index_exports);
51
51
 
52
+ // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/type.js
53
+ function type(input) {
54
+ if (input === null) {
55
+ return "Null";
56
+ } else if (input === void 0) {
57
+ return "Undefined";
58
+ } else if (Number.isNaN(input)) {
59
+ return "NaN";
60
+ }
61
+ const typeResult = Object.prototype.toString.call(input).slice(8, -1);
62
+ return typeResult === "AsyncFunction" ? "Promise" : typeResult;
63
+ }
64
+
65
+ // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/_internals/isArray.js
66
+ var { isArray } = Array;
67
+
68
+ // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/isType.js
69
+ function isType(xType, x) {
70
+ if (arguments.length === 1) {
71
+ return (xHolder) => isType(xType, xHolder);
72
+ }
73
+ return type(x) === xType;
74
+ }
75
+
76
+ // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/clone.js
77
+ function clone(input) {
78
+ const out = isArray(input) ? Array(input.length) : {};
79
+ if (input && input.getTime) return new Date(input.getTime());
80
+ for (const key in input) {
81
+ const v = input[key];
82
+ out[key] = typeof v === "object" && v !== null ? v.getTime ? new Date(v.getTime()) : clone(v) : v;
83
+ }
84
+ return out;
85
+ }
86
+
87
+ // ../../node_modules/.pnpm/rambdax@11.3.1/node_modules/rambdax/src/isNil.js
88
+ function isNil(x) {
89
+ return x === void 0 || x === null;
90
+ }
91
+
52
92
  // src/ValidationError.ts
53
- var import_isPlainObject = __toESM(require("lodash/isPlainObject"), 1);
54
93
  var getPrintableError = (validationErrors) => {
55
94
  const printableErrors = Object.keys(validationErrors).map((key) => {
56
95
  return `${key}: ${validationErrors[key]}`;
@@ -65,7 +104,7 @@ var ValidationError = class _ValidationError extends Error {
65
104
  validationErrors;
66
105
  constructor(validationErrors) {
67
106
  super(getPrintableError(validationErrors));
68
- if (!(0, import_isPlainObject.default)(validationErrors)) {
107
+ if (type(validationErrors) !== "Object") {
69
108
  throw new Error("ValidationError must be initialized with an errors object");
70
109
  }
71
110
  Error.captureStackTrace(this, this.constructor);
@@ -101,14 +140,6 @@ var getSchemaFromTypedSchema = (schema) => {
101
140
  return schema[Symbol.metadata]._getModel().getSchema();
102
141
  };
103
142
 
104
- // src/getValidationErrors/getError/index.ts
105
- var import_isNil2 = __toESM(require("lodash/isNil"), 1);
106
-
107
- // src/getValidationErrors/getError/getFieldValidator.ts
108
- var import_isPlainObject4 = __toESM(require("lodash/isPlainObject"), 1);
109
- var import_isArray3 = __toESM(require("lodash/isArray"), 1);
110
- var import_isString5 = __toESM(require("lodash/isString"), 1);
111
-
112
143
  // src/fieldType.ts
113
144
  function fieldType(opts) {
114
145
  const { name, validate: validate2, clean: clean3, ...otherFields } = opts;
@@ -137,9 +168,6 @@ function fieldType(opts) {
137
168
  };
138
169
  }
139
170
 
140
- // src/fieldTypes/array.ts
141
- var import_isArray = __toESM(require("lodash/isArray"), 1);
142
-
143
171
  // src/Errors.ts
144
172
  var Errors_default = {
145
173
  NOT_IN_SCHEMA: "notInSchema",
@@ -166,11 +194,11 @@ var Errors_default = {
166
194
  var array_default = fieldType({
167
195
  name: "array",
168
196
  validate(value) {
169
- if (!(0, import_isArray.default)(value)) return Errors_default.NOT_AN_ARRAY;
197
+ if (!Array.isArray(value)) return Errors_default.NOT_AN_ARRAY;
170
198
  },
171
199
  clean(value, { options }) {
172
200
  if (options.autoConvert) {
173
- if (!(0, import_isArray.default)(value)) {
201
+ if (!Array.isArray(value)) {
174
202
  value = [value];
175
203
  }
176
204
  }
@@ -179,19 +207,17 @@ var array_default = fieldType({
179
207
  });
180
208
 
181
209
  // src/fieldTypes/plainObject.ts
182
- var import_isPlainObject2 = __toESM(require("lodash/isPlainObject"), 1);
183
- var import_difference = __toESM(require("lodash/difference"), 1);
184
210
  var plainObject_default = fieldType({
185
211
  name: "plainObject",
186
212
  validate(value) {
187
- if (!(0, import_isPlainObject2.default)(value)) return Errors_default.NOT_AN_OBJECT;
213
+ if (type(value) !== "Object") return Errors_default.NOT_AN_OBJECT;
188
214
  },
189
- clean(value, { type, options }) {
190
- if (!(0, import_isPlainObject2.default)(value)) return value;
215
+ clean(value, { type: typeObj, options }) {
216
+ if (type(value) !== "Object") return value;
191
217
  if (options.filter) {
192
218
  const documentKeys = Object.keys(value);
193
- const schemaKeys = Object.keys(type);
194
- const notInSchemaKeys = (0, import_difference.default)(documentKeys, schemaKeys);
219
+ const schemaKeys = Object.keys(typeObj);
220
+ const notInSchemaKeys = documentKeys.filter((key) => !schemaKeys.includes(key));
195
221
  for (const key of notInSchemaKeys) {
196
222
  delete value[key];
197
223
  }
@@ -201,13 +227,10 @@ var plainObject_default = fieldType({
201
227
  });
202
228
 
203
229
  // src/fieldTypes/string.ts
204
- var import_isString = __toESM(require("lodash/isString"), 1);
205
- var import_includes = __toESM(require("lodash/includes"), 1);
206
- var import_isArray2 = __toESM(require("lodash/isArray"), 1);
207
230
  var string_default = fieldType({
208
231
  name: "string",
209
232
  validate(value, { currentSchema }) {
210
- if (!(0, import_isString.default)(value)) return Errors_default.NOT_A_STRING;
233
+ if (typeof value !== "string") return Errors_default.NOT_A_STRING;
211
234
  if (Number.isFinite(currentSchema.min)) {
212
235
  if (value.length < currentSchema.min) {
213
236
  return Errors_default.STRING_TOO_SHORT;
@@ -218,8 +241,8 @@ var string_default = fieldType({
218
241
  return Errors_default.STRING_TOO_LONG;
219
242
  }
220
243
  }
221
- if ((0, import_isArray2.default)(currentSchema.allowedValues)) {
222
- if (!(0, import_includes.default)(currentSchema.allowedValues, value)) {
244
+ if (Array.isArray(currentSchema.allowedValues)) {
245
+ if (!currentSchema.allowedValues.includes(value)) {
223
246
  return Errors_default.NOT_AN_ALLOWED_VALUE;
224
247
  }
225
248
  }
@@ -242,23 +265,20 @@ var string_default = fieldType({
242
265
  });
243
266
 
244
267
  // src/fieldTypes/date.ts
245
- var import_isDate = __toESM(require("lodash/isDate"), 1);
246
- var import_isString2 = __toESM(require("lodash/isString"), 1);
247
- var import_isNumber = __toESM(require("lodash/isNumber"), 1);
248
268
  var date_default = fieldType({
249
269
  name: "date",
250
270
  validate(value) {
251
- if (!(0, import_isDate.default)(value)) return Errors_default.NOT_A_DATE;
271
+ if (!(value instanceof Date)) return Errors_default.NOT_A_DATE;
252
272
  },
253
273
  clean(value, { options }) {
254
274
  if (options.autoConvert) {
255
- if ((0, import_isString2.default)(value)) {
275
+ if (typeof value === "string") {
256
276
  const result = new Date(value);
257
277
  if (Number.isNaN(result.getTime())) {
258
278
  return value;
259
279
  }
260
280
  value = result;
261
- } else if ((0, import_isNumber.default)(value)) {
281
+ } else if (typeof value === "number") {
262
282
  const result = new Date(value);
263
283
  if (Number.isNaN(result.getTime())) {
264
284
  return value;
@@ -270,11 +290,7 @@ var date_default = fieldType({
270
290
  }
271
291
  });
272
292
 
273
- // src/fieldTypes/integer.ts
274
- var import_isInteger = __toESM(require("lodash/isInteger"), 1);
275
-
276
293
  // src/fieldTypes/number.ts
277
- var import_toNumber = __toESM(require("lodash/toNumber"), 1);
278
294
  var number_default = fieldType({
279
295
  name: "number",
280
296
  validate(value, { currentSchema }) {
@@ -292,7 +308,7 @@ var number_default = fieldType({
292
308
  },
293
309
  clean(value, { options: { autoConvert } }) {
294
310
  if (typeof value === "string" && autoConvert) {
295
- value = (0, import_toNumber.default)(value);
311
+ value = Number(value);
296
312
  }
297
313
  return value;
298
314
  }
@@ -302,21 +318,19 @@ var number_default = fieldType({
302
318
  var integer_default = fieldType({
303
319
  name: "integer",
304
320
  validate(value, info) {
305
- if (!(0, import_isInteger.default)(value)) return Errors_default.NOT_AN_INTEGER;
321
+ if (!Number.isInteger(value)) return Errors_default.NOT_AN_INTEGER;
306
322
  return number_default.validate(value, info);
307
323
  }
308
324
  });
309
325
 
310
326
  // src/fieldTypes/ID.ts
311
- var import_isString3 = __toESM(require("lodash/isString"), 1);
312
- var import_isInteger2 = __toESM(require("lodash/isInteger"), 1);
313
327
  var ID_default = fieldType({
314
328
  name: "ID",
315
329
  validate(value) {
316
- if (!(0, import_isString3.default)(value) && !(0, import_isInteger2.default)(value)) return Errors_default.NOT_AN_ID;
330
+ if (typeof value !== "string" && !Number.isInteger(value)) return Errors_default.NOT_AN_ID;
317
331
  },
318
332
  clean(value, { options }) {
319
- if (!(0, import_isString3.default)(value) && !(0, import_isInteger2.default)(value)) return value;
333
+ if (typeof value !== "string" && !Number.isInteger(value)) return value;
320
334
  const { trimStrings, removeEmptyStrings } = options;
321
335
  value = String(value);
322
336
  if (trimStrings) {
@@ -330,11 +344,10 @@ var ID_default = fieldType({
330
344
  });
331
345
 
332
346
  // src/fieldTypes/boolean.ts
333
- var import_isBoolean = __toESM(require("lodash/isBoolean"), 1);
334
347
  var boolean_default = fieldType({
335
348
  name: "boolean",
336
349
  validate(value) {
337
- if (!(0, import_isBoolean.default)(value)) return Errors_default.NOT_A_BOOLEAN;
350
+ if (typeof value !== "boolean") return Errors_default.NOT_A_BOOLEAN;
338
351
  },
339
352
  clean(value, { options }) {
340
353
  if (options.autoConvert) {
@@ -360,15 +373,13 @@ var boolean_default = fieldType({
360
373
  });
361
374
 
362
375
  // src/fieldTypes/email.ts
363
- var import_isString4 = __toESM(require("lodash/isString"), 1);
364
- var import_isNil = __toESM(require("lodash/isNil"), 1);
365
376
  var email_default = fieldType({
366
377
  name: "email",
367
378
  validate(value, { currentSchema }) {
368
- if ((value === "" || (0, import_isNil.default)(value)) && !currentSchema.optional) {
379
+ if ((value === "" || isNil(value)) && !currentSchema.optional) {
369
380
  return Errors_default.REQUIRED;
370
381
  }
371
- if (value && !(0, import_isString4.default)(value)) return Errors_default.NOT_A_STRING;
382
+ if (value && typeof value !== "string") return Errors_default.NOT_A_STRING;
372
383
  const regex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
373
384
  if (value && !regex.test(value)) return Errors_default.NOT_AN_EMAIL;
374
385
  },
@@ -381,11 +392,10 @@ var email_default = fieldType({
381
392
  });
382
393
 
383
394
  // src/fieldTypes/blackbox.ts
384
- var import_isPlainObject3 = __toESM(require("lodash/isPlainObject"), 1);
385
395
  var blackbox_default = fieldType({
386
396
  name: "blackbox",
387
397
  validate(value) {
388
- if (!(0, import_isPlainObject3.default)(value)) return Errors_default.NOT_AN_OBJECT;
398
+ if (type(value) !== "Object") return Errors_default.NOT_AN_OBJECT;
389
399
  }
390
400
  });
391
401
 
@@ -412,33 +422,32 @@ var fieldTypes_default = {
412
422
  };
413
423
 
414
424
  // src/getValidationErrors/getError/getFieldValidator.ts
415
- var import_has = __toESM(require("lodash/has"), 1);
416
- function getFieldValidator(type) {
417
- if ((0, import_isPlainObject4.default)(type)) {
418
- if (type.__isFieldType) return "custom";
425
+ function getFieldValidator(type2) {
426
+ if (isType("Object", type2)) {
427
+ if (type2.__isFieldType) return "custom";
419
428
  return "plainObject";
420
429
  }
421
- if ((0, import_isArray3.default)(type)) return "array";
422
- if (type === String) return "string";
423
- if (typeof type === "function" && type.name === "Date") return "date";
424
- if (type === Number) return "number";
425
- if (type === Boolean) return "boolean";
426
- if (type === "enum") return "string";
427
- if (!(0, import_isString5.default)(type)) {
428
- throw new Error(`Field type is invalid. Pass a string or a custom field type. Got ${type}`);
430
+ if (Array.isArray(type2)) return "array";
431
+ if (type2 === String) return "string";
432
+ if (typeof type2 === "function" && type2.name === "Date") return "date";
433
+ if (type2 === Number) return "number";
434
+ if (type2 === Boolean) return "boolean";
435
+ if (type2 === "enum") return "string";
436
+ if (typeof type2 !== "string") {
437
+ throw new Error(`Field type is invalid. Pass a string or a custom field type. Got ${type2}`);
429
438
  }
430
- const exists = (0, import_has.default)(fieldTypes_default, type);
439
+ const exists = fieldTypes_default[type2];
431
440
  if (!exists) {
432
441
  throw new Error("Field type does not exist");
433
442
  }
434
- return type;
443
+ return type2;
435
444
  }
436
445
 
437
446
  // src/getValidationErrors/getError/index.ts
438
447
  async function getValidationErrors(params) {
439
448
  const { schema, doc, currentDoc, value, currentSchema, keys, options = {}, args = [] } = params;
440
449
  const info = { schema, doc, currentDoc, keys, currentSchema, options };
441
- if ((0, import_isNil2.default)(value)) {
450
+ if (isNil(value)) {
442
451
  if (!currentSchema.optional && !options.omitRequired) {
443
452
  return Errors_default.REQUIRED;
444
453
  }
@@ -457,9 +466,9 @@ async function getValidationErrors(params) {
457
466
  return customError;
458
467
  }
459
468
  }
460
- const type = currentSchema.type;
461
- if (type.__validate) {
462
- const typeError = await type.__validate(value, info, ...args);
469
+ const type2 = currentSchema.type;
470
+ if (type2.__validate) {
471
+ const typeError = await type2.__validate(value, info, ...args);
463
472
  if (typeError) {
464
473
  return typeError;
465
474
  }
@@ -467,25 +476,29 @@ async function getValidationErrors(params) {
467
476
  return null;
468
477
  }
469
478
 
470
- // src/getValidationErrors/doValidation.ts
471
- var import_isPlainObject5 = __toESM(require("lodash/isPlainObject"), 1);
472
- var import_isArray4 = __toESM(require("lodash/isArray"), 1);
473
- var import_clone = __toESM(require("lodash/clone"), 1);
474
- var import_isNil3 = __toESM(require("lodash/isNil"), 1);
475
- var import_difference2 = __toESM(require("lodash/difference"), 1);
476
-
477
479
  // src/getValidationErrors/convertTypedSchema.ts
478
480
  var convertOnParam = (info, paramName) => {
479
481
  if (!info[paramName]) return;
480
- const type = info[paramName].type;
481
- if (!type) return;
482
- info[paramName].type = getSchemaFromTypedSchema(type);
482
+ const type2 = info[paramName].type;
483
+ if (!type2) return;
484
+ info[paramName].type = getSchemaFromTypedSchema(type2);
483
485
  };
484
486
  var convertTypedSchema = (info) => {
485
487
  convertOnParam(info, "schema");
486
488
  convertOnParam(info, "currentSchema");
487
489
  };
488
490
 
491
+ // src/clone.ts
492
+ function clone2(value) {
493
+ if (isType("Object", value)) {
494
+ return clone(value);
495
+ }
496
+ if (Array.isArray(value)) {
497
+ return clone(value);
498
+ }
499
+ return value;
500
+ }
501
+
489
502
  // src/getValidationErrors/doValidation.ts
490
503
  async function doValidation(params) {
491
504
  convertTypedSchema(params);
@@ -496,15 +509,15 @@ async function doValidation(params) {
496
509
  addError(keys, error);
497
510
  return;
498
511
  }
499
- if ((0, import_isNil3.default)(value)) return;
500
- if ((0, import_isPlainObject5.default)(currentSchema.type)) {
501
- const type = currentSchema.type;
502
- if (type) {
503
- if (type.__isFieldType) {
512
+ if (isNil(value)) return;
513
+ if (type(currentSchema.type) === "Object") {
514
+ const type2 = currentSchema.type;
515
+ if (type2) {
516
+ if (type2.__isFieldType) {
504
517
  return;
505
518
  }
506
- if (typeof type.__skipChildValidation === "function") {
507
- if (await type.__skipChildValidation(value, info)) {
519
+ if (typeof type2.__skipChildValidation === "function") {
520
+ if (await type2.__skipChildValidation(value, info)) {
508
521
  return;
509
522
  }
510
523
  }
@@ -513,7 +526,7 @@ async function doValidation(params) {
513
526
  for (const key of schemaKeys) {
514
527
  const itemSchema = currentSchema.type[key];
515
528
  const itemValue = value[key];
516
- const keyItemKeys = (0, import_clone.default)(keys);
529
+ const keyItemKeys = clone2(keys);
517
530
  keyItemKeys.push(key);
518
531
  await doValidation({
519
532
  ...info,
@@ -524,17 +537,17 @@ async function doValidation(params) {
524
537
  });
525
538
  }
526
539
  const documentKeys = Object.keys(value);
527
- const notInSchemaKeys = (0, import_difference2.default)(documentKeys, schemaKeys);
540
+ const notInSchemaKeys = documentKeys.filter((key) => !schemaKeys.includes(key));
528
541
  for (const key of notInSchemaKeys) {
529
- const keyItemKeys = (0, import_clone.default)(keys);
542
+ const keyItemKeys = clone2(keys);
530
543
  keyItemKeys.push(key);
531
544
  addError(keyItemKeys, Errors_default.NOT_IN_SCHEMA);
532
545
  }
533
- } else if ((0, import_isArray4.default)(currentSchema.type)) {
546
+ } else if (Array.isArray(currentSchema.type)) {
534
547
  const itemSchema = currentSchema.type[0];
535
548
  for (let i = 0; i < value.length; i++) {
536
549
  const itemValue = value[i];
537
- const keyItemKeys = (0, import_clone.default)(keys);
550
+ const keyItemKeys = clone2(keys);
538
551
  keyItemKeys.push(i.toString());
539
552
  await doValidation({
540
553
  ...info,
@@ -601,23 +614,15 @@ async function isValid(schema, doc, passedOptions = {}, ...args) {
601
614
  }
602
615
 
603
616
  // src/getValidationErrors/getError/getFieldType.ts
604
- function getFieldType(type) {
605
- const validatorKey = getFieldValidator(type);
606
- const validator = validatorKey === "custom" ? type : fieldTypes_default[validatorKey];
617
+ function getFieldType(type2) {
618
+ const validatorKey = getFieldValidator(type2);
619
+ const validator = validatorKey === "custom" ? type2 : fieldTypes_default[validatorKey];
607
620
  return validator;
608
621
  }
609
622
 
610
- // src/clean/recursiveClean.ts
611
- var import_isUndefined = __toESM(require("lodash/isUndefined"), 1);
612
- var import_isArray5 = __toESM(require("lodash/isArray"), 1);
613
-
614
- // src/clean/cleanType.ts
615
- var import_isNil4 = __toESM(require("lodash/isNil"), 1);
616
-
617
623
  // src/clean/getObjectNode.ts
618
- var import_isPlainObject6 = __toESM(require("lodash/isPlainObject"), 1);
619
624
  function getObjectNode(schema, value) {
620
- if ((0, import_isPlainObject6.default)(schema.type) && (0, import_isPlainObject6.default)(value)) {
625
+ if (type(schema.type) === "Object" && type(value) === "Object") {
621
626
  const result = schema;
622
627
  return result;
623
628
  }
@@ -625,13 +630,13 @@ function getObjectNode(schema, value) {
625
630
  }
626
631
 
627
632
  // src/clean/cleanType.ts
628
- async function cleanType(type, fieldSchema, value, info, ...args) {
633
+ async function cleanType(type2, fieldSchema, value, info, ...args) {
629
634
  info.type = fieldSchema.type;
630
635
  if (!info.type) {
631
636
  throw new Error("Cleaning field with no type");
632
637
  }
633
- const { clean: rootFieldClean } = await getFieldType(type);
634
- if (rootFieldClean && !(0, import_isNil4.default)(value)) {
638
+ const { clean: rootFieldClean } = await getFieldType(type2);
639
+ if (rootFieldClean && !isNil(value)) {
635
640
  value = await rootFieldClean(value, info, ...args);
636
641
  }
637
642
  let needReClean = false;
@@ -641,7 +646,7 @@ async function cleanType(type, fieldSchema, value, info, ...args) {
641
646
  value = await objectTypeSchema.type.__clean(value, info, ...args);
642
647
  }
643
648
  const { defaultValue } = fieldSchema;
644
- if ((0, import_isNil4.default)(value) && !(0, import_isNil4.default)(defaultValue)) {
649
+ if (isNil(value) && !isNil(defaultValue)) {
645
650
  needReClean = true;
646
651
  if (typeof defaultValue === "function") {
647
652
  value = await defaultValue(info, ...args);
@@ -654,14 +659,13 @@ async function cleanType(type, fieldSchema, value, info, ...args) {
654
659
  needReClean = true;
655
660
  value = await clean3(value, info, ...args);
656
661
  }
657
- if (needReClean && rootFieldClean && !(0, import_isNil4.default)(value)) {
662
+ if (needReClean && rootFieldClean && !isNil(value)) {
658
663
  value = await rootFieldClean(value, info, ...args);
659
664
  }
660
665
  return value;
661
666
  }
662
667
 
663
668
  // src/clean/recursiveClean.ts
664
- var import_isNil5 = __toESM(require("lodash/isNil"), 1);
665
669
  var cleanObjectFields = async ({
666
670
  schema,
667
671
  value,
@@ -678,7 +682,7 @@ var cleanObjectFields = async ({
678
682
  currentDoc: value
679
683
  };
680
684
  const newValue = await clean(cleanOptions);
681
- if (!(0, import_isUndefined.default)(newValue)) {
685
+ if (newValue !== void 0) {
682
686
  newDoc[key] = newValue;
683
687
  }
684
688
  } catch (error) {
@@ -705,10 +709,10 @@ var cleanArrayItems = async ({
705
709
  return newValue;
706
710
  });
707
711
  const result = await Promise.all(promises);
708
- return result.filter((value2) => !(0, import_isUndefined.default)(value2));
712
+ return result.filter((value2) => value2 !== void 0);
709
713
  };
710
714
  function getArrayNode(schema, value) {
711
- if ((0, import_isArray5.default)(schema.type) && !(0, import_isNil5.default)(value)) {
715
+ if (Array.isArray(schema.type) && !isNil(value)) {
712
716
  const result = schema;
713
717
  return result;
714
718
  }
@@ -731,7 +735,7 @@ var clean = async (info) => {
731
735
  const arraySchema = getArrayNode(currSchema, value);
732
736
  if (arraySchema) {
733
737
  let updatedValue = value;
734
- if (!(0, import_isArray5.default)(value) && !Array.isArray(value)) {
738
+ if (!Array.isArray(value)) {
735
739
  updatedValue = [value];
736
740
  }
737
741
  const newDoc = await cleanArrayItems({
@@ -771,8 +775,6 @@ async function clean2(schema, doc, opts = {}, ...args) {
771
775
  }
772
776
 
773
777
  // src/validateKey/dotGetSchema.ts
774
- var import_isPlainObject7 = __toESM(require("lodash/isPlainObject"), 1);
775
- var import_isNil6 = __toESM(require("lodash/isNil"), 1);
776
778
  var dotGet = function dotGet2(object, path) {
777
779
  if (path === "") return object;
778
780
  const pathParts = path.split(".");
@@ -782,7 +784,7 @@ var dotGet = function dotGet2(object, path) {
782
784
  if (first === "$" || /^[0-9]+$/.test(first)) {
783
785
  return dotGet2({ type: levelObject[0] }, remainingPath);
784
786
  }
785
- if ((0, import_isPlainObject7.default)(levelObject[first])) {
787
+ if (isType("Object", levelObject[first])) {
786
788
  return dotGet2(levelObject[first], remainingPath);
787
789
  }
788
790
  if (levelObject === "blackbox") {
@@ -791,7 +793,7 @@ var dotGet = function dotGet2(object, path) {
791
793
  return null;
792
794
  };
793
795
  function dotGetSchema_default(schema, path) {
794
- if ((0, import_isNil6.default)(schema)) {
796
+ if (isNil(schema)) {
795
797
  throw new Error("You need to pass a schema");
796
798
  }
797
799
  return dotGet({ type: schema }, path);
@@ -845,8 +847,6 @@ async function validateKey_default(schema, key, value, passedOptions = {}, ...ar
845
847
  }
846
848
 
847
849
  // src/fieldTypes/enum.ts
848
- var import_isString6 = __toESM(require("lodash/isString"), 1);
849
- var import_includes2 = __toESM(require("lodash/includes"), 1);
850
850
  function createEnum(name, values) {
851
851
  return {
852
852
  type: values[0],
@@ -868,8 +868,8 @@ function createEnum(name, values) {
868
868
  return global.GraphQLEnums[name];
869
869
  },
870
870
  validate(value, { currentSchema }) {
871
- if (!(0, import_isString6.default)(value)) return Errors_default.NOT_A_STRING;
872
- if (!(0, import_includes2.default)(values, value)) {
871
+ if (typeof value !== "string") return Errors_default.NOT_A_STRING;
872
+ if (!values.includes(value)) {
873
873
  return Errors_default.NOT_AN_ALLOWED_VALUE;
874
874
  }
875
875
  if (value === "" && !currentSchema.optional) {
@@ -894,51 +894,51 @@ function createEnum(name, values) {
894
894
 
895
895
  // src/models.ts
896
896
  Symbol.metadata ?? (Symbol.metadata = Symbol("Symbol.metadata"));
897
- function isSchemaLike(type) {
897
+ function isSchemaLike(type2) {
898
898
  var _a;
899
- if (!type) return false;
900
- if (objectHasSubObjectWithKey(type, "type")) return true;
901
- if ((_a = type == null ? void 0 : type[Symbol.metadata]) == null ? void 0 : _a._getModel) return true;
902
- if (type.getModel) return true;
903
- if (type.getSchema) return true;
904
- if (type.getCleanSchema) return true;
905
- if (type.__isModel) return true;
906
- if (type.__modelName) return true;
899
+ if (!type2) return false;
900
+ if (objectHasSubObjectWithKey(type2, "type")) return true;
901
+ if ((_a = type2 == null ? void 0 : type2[Symbol.metadata]) == null ? void 0 : _a._getModel) return true;
902
+ if (type2.getModel) return true;
903
+ if (type2.getSchema) return true;
904
+ if (type2.getCleanSchema) return true;
905
+ if (type2.__isModel) return true;
906
+ if (type2.__modelName) return true;
907
907
  return false;
908
908
  }
909
- function isSchemaOrFieldLike(type) {
910
- if (Array.isArray(type)) {
911
- if (type.length !== 1) return false;
912
- return isSchemaOrFieldLike(type[0]);
909
+ function isSchemaOrFieldLike(type2) {
910
+ if (Array.isArray(type2)) {
911
+ if (type2.length !== 1) return false;
912
+ return isSchemaOrFieldLike(type2[0]);
913
913
  }
914
- if (isSchemaLike(type)) return true;
914
+ if (isSchemaLike(type2)) return true;
915
915
  try {
916
- if (getFieldValidator(type)) return true;
916
+ if (getFieldValidator(type2)) return true;
917
917
  } catch {
918
918
  return false;
919
919
  }
920
920
  return false;
921
921
  }
922
- function getSchemaModelName(type) {
923
- if (!type) return null;
924
- if (type.__modelName) return type.__modelName;
925
- if (type.getModel) return type.getModel().name;
926
- if (type.getSchema) return type.getSchema().__modelName;
922
+ function getSchemaModelName(type2) {
923
+ if (!type2) return null;
924
+ if (type2.__modelName) return type2.__modelName;
925
+ if (type2.getModel) return type2.getModel().name;
926
+ if (type2.getSchema) return type2.getSchema().__modelName;
927
927
  return null;
928
928
  }
929
- function getSchemaFromAnyOrionForm(type) {
929
+ function getSchemaFromAnyOrionForm(type2) {
930
930
  var _a, _b;
931
- if ((_a = type == null ? void 0 : type[Symbol.metadata]) == null ? void 0 : _a._getModel) {
932
- return (_b = type == null ? void 0 : type[Symbol.metadata]) == null ? void 0 : _b._getModel().getSchema();
931
+ if ((_a = type2 == null ? void 0 : type2[Symbol.metadata]) == null ? void 0 : _a._getModel) {
932
+ return (_b = type2 == null ? void 0 : type2[Symbol.metadata]) == null ? void 0 : _b._getModel().getSchema();
933
933
  }
934
- if (type == null ? void 0 : type.getModel) return type.getModel().getSchema();
935
- if (type.getSchema) {
936
- return type.getSchema();
934
+ if (type2 == null ? void 0 : type2.getModel) return type2.getModel().getSchema();
935
+ if (type2.getSchema) {
936
+ return type2.getSchema();
937
937
  }
938
- if (type.getSchema) {
939
- return type.getSchema();
938
+ if (type2.getSchema) {
939
+ return type2.getSchema();
940
940
  }
941
- if (objectHasSubObjectWithKey(type, "type")) return type;
941
+ if (objectHasSubObjectWithKey(type2, "type")) return type2;
942
942
  return null;
943
943
  }
944
944
  function objectHasSubObjectWithKey(object, key) {
@@ -951,8 +951,8 @@ function objectHasSubObjectWithKey(object, key) {
951
951
  }
952
952
  return false;
953
953
  }
954
- function getSchemaWithMetadataFromAnyOrionForm(type) {
955
- return getSchemaFromAnyOrionForm(type);
954
+ function getSchemaWithMetadataFromAnyOrionForm(type2) {
955
+ return getSchemaFromAnyOrionForm(type2);
956
956
  }
957
957
 
958
958
  // src/schemaWithName/index.ts