not-node 5.1.32 → 5.1.33
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/package.json +1 -1
- package/src/form/form.js +35 -0
package/package.json
CHANGED
package/src/form/form.js
CHANGED
|
@@ -243,6 +243,41 @@ class Form {
|
|
|
243
243
|
}
|
|
244
244
|
return results;
|
|
245
245
|
}
|
|
246
|
+
|
|
247
|
+
createInstructionFromRouteActionFields(
|
|
248
|
+
req,
|
|
249
|
+
mainInstruction = "fromBody",
|
|
250
|
+
exceptions = {}
|
|
251
|
+
) {
|
|
252
|
+
const result = {};
|
|
253
|
+
if (
|
|
254
|
+
req?.notRouteData?.actionData?.fields &&
|
|
255
|
+
Array.isArray(req.notRouteData.actionData.fields)
|
|
256
|
+
) {
|
|
257
|
+
const fields = req.notRouteData.actionData.fields.flat(2);
|
|
258
|
+
fields.forEach((fieldName) => {
|
|
259
|
+
if (objHas(exceptions, fieldName)) {
|
|
260
|
+
result[fieldName] = exceptions[fieldName];
|
|
261
|
+
} else {
|
|
262
|
+
result[fieldName] = mainInstruction;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
extractByInstructionsFromRouteActionFields(
|
|
270
|
+
req,
|
|
271
|
+
mainInstruction = "fromBody",
|
|
272
|
+
exceptions = {}
|
|
273
|
+
) {
|
|
274
|
+
const instructions = this.createInstructionFromRouteActionFields(
|
|
275
|
+
req,
|
|
276
|
+
mainInstruction,
|
|
277
|
+
exceptions
|
|
278
|
+
);
|
|
279
|
+
return this.extractByInstructions(req, instructions);
|
|
280
|
+
}
|
|
246
281
|
}
|
|
247
282
|
|
|
248
283
|
module.exports = Form;
|