@naturalcycles/nodejs-lib 15.12.0 → 15.13.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _isObject, _lazyValue, } from '@naturalcycles/js-lib';
|
|
2
2
|
import { JsonSchemaAnyBuilder } from '@naturalcycles/js-lib/json-schema';
|
|
3
|
-
import { _filterNullishValues } from '@naturalcycles/js-lib/object';
|
|
3
|
+
import { _deepCopy, _filterNullishValues } from '@naturalcycles/js-lib/object';
|
|
4
4
|
import { _substringBefore } from '@naturalcycles/js-lib/string';
|
|
5
5
|
import { z } from '@naturalcycles/js-lib/zod';
|
|
6
6
|
import { _inspect } from '../../string/inspect.js';
|
|
@@ -76,7 +76,7 @@ export class AjvSchema {
|
|
|
76
76
|
}
|
|
77
77
|
getValidationResult(input, opt = {}) {
|
|
78
78
|
const fn = this.getAJVValidateFunction();
|
|
79
|
-
const item = opt.mutateInput || typeof input !== 'object' ? input :
|
|
79
|
+
const item = opt.mutateInput || typeof input !== 'object' ? input : _deepCopy(input);
|
|
80
80
|
const valid = fn(item); // mutates item
|
|
81
81
|
if (valid)
|
|
82
82
|
return [null, item];
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from '@naturalcycles/js-lib'
|
|
7
7
|
import type { JsonSchema, JsonSchemaBuilder } from '@naturalcycles/js-lib/json-schema'
|
|
8
8
|
import { JsonSchemaAnyBuilder } from '@naturalcycles/js-lib/json-schema'
|
|
9
|
-
import { _filterNullishValues } from '@naturalcycles/js-lib/object'
|
|
9
|
+
import { _deepCopy, _filterNullishValues } from '@naturalcycles/js-lib/object'
|
|
10
10
|
import { _substringBefore } from '@naturalcycles/js-lib/string'
|
|
11
11
|
import { z, type ZodType } from '@naturalcycles/js-lib/zod'
|
|
12
12
|
import type { Ajv } from 'ajv'
|
|
@@ -140,7 +140,7 @@ export class AjvSchema<T = unknown> {
|
|
|
140
140
|
): ValidationFunctionResult<T, AjvValidationError> {
|
|
141
141
|
const fn = this.getAJVValidateFunction()
|
|
142
142
|
|
|
143
|
-
const item = opt.mutateInput || typeof input !== 'object' ? input :
|
|
143
|
+
const item = opt.mutateInput || typeof input !== 'object' ? input : _deepCopy(input)
|
|
144
144
|
|
|
145
145
|
const valid = fn(item) // mutates item
|
|
146
146
|
if (valid) return [null, item]
|