@autofleet/sadot 0.13.0-beta.10 → 0.13.0-beta.11
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/hooks/hooks.js +4 -4
- package/package.json +1 -1
- package/src/hooks/hooks.ts +4 -4
package/dist/hooks/hooks.js
CHANGED
|
@@ -107,12 +107,12 @@ const validateModel = async (instance, options, scopeAttributes, isCreate = fals
|
|
|
107
107
|
after: typedSchema.properties.after,
|
|
108
108
|
},
|
|
109
109
|
});
|
|
110
|
-
const isValid = validateSchema(JSON.stringify({
|
|
110
|
+
const isValid = validateSchema(JSON.parse(JSON.stringify({
|
|
111
111
|
after: {
|
|
112
112
|
...instance.dataValues,
|
|
113
113
|
customFields: instance.customFields,
|
|
114
114
|
},
|
|
115
|
-
}));
|
|
115
|
+
})));
|
|
116
116
|
if (!isValid) {
|
|
117
117
|
const errorDetails = validateSchema.errors?.map((err) => `${err.instancePath || ''} ${err.message || 'Invalid value'}`).join(', ');
|
|
118
118
|
throw new errors_1.BadRequest([new Error(`Validation failed for ${modelType}: ${errorDetails}`)]);
|
|
@@ -122,13 +122,13 @@ const validateModel = async (instance, options, scopeAttributes, isCreate = fals
|
|
|
122
122
|
else {
|
|
123
123
|
// For update operations, we need both before and after
|
|
124
124
|
const validateSchema = ajv.compile(typedSchema);
|
|
125
|
-
const isValid = validateSchema(JSON.stringify({
|
|
125
|
+
const isValid = validateSchema(JSON.parse(JSON.stringify({
|
|
126
126
|
before: originalValues,
|
|
127
127
|
after: {
|
|
128
128
|
...instance.dataValues,
|
|
129
129
|
customFields: instance.customFields,
|
|
130
130
|
},
|
|
131
|
-
}));
|
|
131
|
+
})));
|
|
132
132
|
logger_1.default.info('sadot - validation result', {
|
|
133
133
|
isValid,
|
|
134
134
|
test: {
|
package/package.json
CHANGED
package/src/hooks/hooks.ts
CHANGED
|
@@ -107,12 +107,12 @@ const validateModel = async (
|
|
|
107
107
|
},
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
const isValid = validateSchema(JSON.stringify({
|
|
110
|
+
const isValid = validateSchema(JSON.parse(JSON.stringify({
|
|
111
111
|
after: {
|
|
112
112
|
...instance.dataValues,
|
|
113
113
|
customFields: instance.customFields,
|
|
114
114
|
},
|
|
115
|
-
}));
|
|
115
|
+
})));
|
|
116
116
|
|
|
117
117
|
if (!isValid) {
|
|
118
118
|
const errorDetails = validateSchema.errors?.map((err) =>
|
|
@@ -125,13 +125,13 @@ const validateModel = async (
|
|
|
125
125
|
// For update operations, we need both before and after
|
|
126
126
|
const validateSchema = ajv.compile(typedSchema);
|
|
127
127
|
|
|
128
|
-
const isValid = validateSchema(JSON.stringify({
|
|
128
|
+
const isValid = validateSchema(JSON.parse(JSON.stringify({
|
|
129
129
|
before: originalValues,
|
|
130
130
|
after: {
|
|
131
131
|
...instance.dataValues,
|
|
132
132
|
customFields: instance.customFields,
|
|
133
133
|
},
|
|
134
|
-
}));
|
|
134
|
+
})));
|
|
135
135
|
|
|
136
136
|
logger.info('sadot - validation result', {
|
|
137
137
|
isValid,
|