Skip to content

Commit 8a63988

Browse files
committed
update: add AJV with coerceTypes
1 parent 48e5244 commit 8a63988

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"devDependencies": {
8181
"@babel/preset-typescript": "^7.22.5",
8282
"@exabyte-io/eslint-config": "^2023.8.29-1",
83-
"@mat3ra/esse": "git+https://github.com/Exabyte-io/esse.git#33f3c221536f75a93291a65289c75a0043ddbbd6",
83+
"@mat3ra/esse": "git+https://github.com/Exabyte-io/esse.git#fa660c7668fd48414dfee53ecccc3625b5ed28c6",
8484
"@typescript-eslint/eslint-plugin": "^5.56.0",
8585
"@typescript-eslint/parser": "^5.56.0",
8686
"chai": "^4.3.4",

src/entity/in_memory.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export class InMemoryEntity {
4040
// Override if deepClone of config is required
4141
static _isDeepCloneRequired = false;
4242

43+
static allowJsonSchemaTypesCoercing = false;
44+
4345
static readonly jsonSchema?: JSONSchema;
4446

4547
_json: AnyObject = {};
@@ -112,7 +114,9 @@ export class InMemoryEntity {
112114
return data;
113115
}
114116
const result = clean
115-
? ajv.validateAndClean(data, this.jsonSchema)
117+
? ajv.validateAndClean(data, this.jsonSchema, {
118+
coerceTypes: this.allowJsonSchemaTypesCoercing,
119+
})
116120
: ajv.validate(data, this.jsonSchema);
117121

118122
if (!result.isValid) {

0 commit comments

Comments
 (0)