@naturalcycles/db-lib 10.9.0 → 10.10.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/commondao/common.dao.js +10 -9
- package/package.json +2 -2
- package/src/commondao/common.dao.ts +11 -11
|
@@ -967,29 +967,30 @@ export class CommonDao {
|
|
|
967
967
|
let convertedValue;
|
|
968
968
|
if (this.cfg.validateBM) {
|
|
969
969
|
const [err, value] = this.cfg.validateBM(obj, {
|
|
970
|
-
|
|
970
|
+
inputName: table,
|
|
971
971
|
});
|
|
972
972
|
error = err;
|
|
973
973
|
convertedValue = value;
|
|
974
974
|
}
|
|
975
975
|
else if (schema instanceof ZodType) {
|
|
976
976
|
// Zod schema
|
|
977
|
-
const
|
|
978
|
-
error =
|
|
979
|
-
convertedValue =
|
|
977
|
+
const [err, value] = zSafeValidate(obj, schema);
|
|
978
|
+
error = err;
|
|
979
|
+
convertedValue = value;
|
|
980
980
|
}
|
|
981
981
|
else if (schema instanceof AjvSchema) {
|
|
982
982
|
// Ajv schema
|
|
983
|
-
|
|
984
|
-
error = schema.getValidationError(obj, {
|
|
983
|
+
const [err, value] = schema.getValidationResult(obj, {
|
|
985
984
|
objectName,
|
|
986
985
|
});
|
|
986
|
+
error = err;
|
|
987
|
+
convertedValue = value;
|
|
987
988
|
}
|
|
988
989
|
else {
|
|
989
990
|
// Joi
|
|
990
|
-
const
|
|
991
|
-
error =
|
|
992
|
-
convertedValue =
|
|
991
|
+
const [err, value] = getValidationResult(obj, schema, objectName);
|
|
992
|
+
error = err;
|
|
993
|
+
convertedValue = value;
|
|
993
994
|
}
|
|
994
995
|
// If we care about validation and there's an error
|
|
995
996
|
if (error) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/db-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.10.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@naturalcycles/js-lib": "^15",
|
|
7
7
|
"@naturalcycles/nodejs-lib": "^15"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@naturalcycles/dev-lib": "19.
|
|
10
|
+
"@naturalcycles/dev-lib": "19.14.0"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
@@ -1239,32 +1239,32 @@ export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM, I
|
|
|
1239
1239
|
const table = opt.table || this.cfg.table
|
|
1240
1240
|
const objectName = table
|
|
1241
1241
|
|
|
1242
|
-
let error: JoiValidationError | AjvValidationError | ZodValidationError | undefined
|
|
1242
|
+
let error: JoiValidationError | AjvValidationError | ZodValidationError | null | undefined
|
|
1243
1243
|
let convertedValue: any
|
|
1244
1244
|
|
|
1245
1245
|
if (this.cfg.validateBM) {
|
|
1246
1246
|
const [err, value] = this.cfg.validateBM(obj as any as BM, {
|
|
1247
|
-
|
|
1247
|
+
inputName: table,
|
|
1248
1248
|
})
|
|
1249
1249
|
error = err
|
|
1250
1250
|
convertedValue = value
|
|
1251
1251
|
} else if (schema instanceof ZodType) {
|
|
1252
1252
|
// Zod schema
|
|
1253
|
-
const
|
|
1254
|
-
error =
|
|
1255
|
-
convertedValue =
|
|
1253
|
+
const [err, value] = zSafeValidate(obj as T, schema)
|
|
1254
|
+
error = err
|
|
1255
|
+
convertedValue = value
|
|
1256
1256
|
} else if (schema instanceof AjvSchema) {
|
|
1257
1257
|
// Ajv schema
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
error = schema.getValidationError(obj as T, {
|
|
1258
|
+
const [err, value] = schema.getValidationResult(obj as T, {
|
|
1261
1259
|
objectName,
|
|
1262
1260
|
})
|
|
1261
|
+
error = err
|
|
1262
|
+
convertedValue = value
|
|
1263
1263
|
} else {
|
|
1264
1264
|
// Joi
|
|
1265
|
-
const
|
|
1266
|
-
error =
|
|
1267
|
-
convertedValue =
|
|
1265
|
+
const [err, value] = getValidationResult(obj, schema, objectName)
|
|
1266
|
+
error = err
|
|
1267
|
+
convertedValue = value
|
|
1268
1268
|
}
|
|
1269
1269
|
|
|
1270
1270
|
// If we care about validation and there's an error
|