@budibase/backend-core 2.27.6 → 2.28.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/index.js +16 -7
- package/dist/index.js.map +3 -3
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/src/middleware/joi-validator.d.ts +6 -2
- package/dist/src/middleware/joi-validator.js +10 -6
- package/dist/src/middleware/joi-validator.js.map +1 -1
- package/package.json +4 -4
- package/src/middleware/joi-validator.ts +17 -6
package/dist/index.js
CHANGED
|
@@ -55021,12 +55021,17 @@ function validate(cronExpression) {
|
|
|
55021
55021
|
// ../shared-core/src/helpers/schema.ts
|
|
55022
55022
|
var schema_exports = {};
|
|
55023
55023
|
__export(schema_exports, {
|
|
55024
|
-
isDeprecatedSingleUserColumn: () => isDeprecatedSingleUserColumn
|
|
55024
|
+
isDeprecatedSingleUserColumn: () => isDeprecatedSingleUserColumn,
|
|
55025
|
+
isRequired: () => isRequired
|
|
55025
55026
|
});
|
|
55026
55027
|
function isDeprecatedSingleUserColumn(schema) {
|
|
55027
55028
|
const result = schema.type === "bb_reference" /* BB_REFERENCE */ && schema.subtype === "user" /* USER */ && schema.constraints?.type !== "array";
|
|
55028
55029
|
return result;
|
|
55029
55030
|
}
|
|
55031
|
+
function isRequired(constraints) {
|
|
55032
|
+
const isRequired2 = !!constraints && (typeof constraints.presence !== "boolean" && constraints.presence?.allowEmpty === false || constraints.presence === true);
|
|
55033
|
+
return isRequired2;
|
|
55034
|
+
}
|
|
55030
55035
|
|
|
55031
55036
|
// ../shared-core/src/filters.ts
|
|
55032
55037
|
var HBS_REGEX = /{{([^{].*?)}}/g;
|
|
@@ -66466,7 +66471,7 @@ __export(joi_validator_exports, {
|
|
|
66466
66471
|
params: () => params
|
|
66467
66472
|
});
|
|
66468
66473
|
var import_joi = __toESM(require("joi"));
|
|
66469
|
-
function validate2(schema, property) {
|
|
66474
|
+
function validate2(schema, property, opts = { errorPrefix: `Invalid ${property}` }) {
|
|
66470
66475
|
return (ctx, next) => {
|
|
66471
66476
|
if (!schema) {
|
|
66472
66477
|
return next();
|
|
@@ -66486,16 +66491,20 @@ function validate2(schema, property) {
|
|
|
66486
66491
|
}
|
|
66487
66492
|
const { error } = schema.validate(params2);
|
|
66488
66493
|
if (error) {
|
|
66489
|
-
|
|
66494
|
+
let message = error.message;
|
|
66495
|
+
if (opts.errorPrefix) {
|
|
66496
|
+
message = `Invalid ${property} - ${message}`;
|
|
66497
|
+
}
|
|
66498
|
+
ctx.throw(400, message);
|
|
66490
66499
|
}
|
|
66491
66500
|
return next();
|
|
66492
66501
|
};
|
|
66493
66502
|
}
|
|
66494
|
-
function body(schema) {
|
|
66495
|
-
return validate2(schema, "body");
|
|
66503
|
+
function body(schema, opts) {
|
|
66504
|
+
return validate2(schema, "body", opts);
|
|
66496
66505
|
}
|
|
66497
|
-
function params(schema) {
|
|
66498
|
-
return validate2(schema, "params");
|
|
66506
|
+
function params(schema, opts) {
|
|
66507
|
+
return validate2(schema, "params", opts);
|
|
66499
66508
|
}
|
|
66500
66509
|
|
|
66501
66510
|
// src/middleware/index.ts
|