@headless-adminapp/app 1.2.0 → 1.2.1
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/dataform/utils/index.js
CHANGED
|
@@ -33,6 +33,8 @@ const utils_1 = require("../../dataform/DataFormProvider/utils");
|
|
|
33
33
|
const utils_2 = require("../../locale/utils");
|
|
34
34
|
var saveRecord_1 = require("./saveRecord");
|
|
35
35
|
Object.defineProperty(exports, "saveRecord", { enumerable: true, get: function () { return saveRecord_1.saveRecord; } });
|
|
36
|
+
const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
37
|
+
const objectIdRegex = /^[0-9a-f]{24}$/i;
|
|
36
38
|
function getInitialValues({ cloneRecord, form, record, recordId, schema, defaultParameters, }) {
|
|
37
39
|
const formColumns = (0, utils_1.getColumns)(form, schema);
|
|
38
40
|
const editableGridControls = (0, utils_1.getControls)(form).filter((control) => control.type === 'editablegrid' && control.alias !== false);
|
|
@@ -253,6 +255,14 @@ function createAttributeValidationSchema(attribute) {
|
|
|
253
255
|
case 'lookups':
|
|
254
256
|
validationSchema = yup.array().nullable();
|
|
255
257
|
break;
|
|
258
|
+
case 'id':
|
|
259
|
+
if ('number' in attribute && attribute.number) {
|
|
260
|
+
validationSchema = yup.number().nullable();
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
validationSchema = yup.string().nullable();
|
|
264
|
+
}
|
|
265
|
+
break;
|
|
256
266
|
default:
|
|
257
267
|
validationSchema = yup.mixed().nullable();
|
|
258
268
|
break;
|
|
@@ -284,6 +294,14 @@ function extendAttributeValidationSchema({ attribute, validationSchema, label, s
|
|
|
284
294
|
strings,
|
|
285
295
|
});
|
|
286
296
|
break;
|
|
297
|
+
case 'id':
|
|
298
|
+
validationSchema = extendAttributeIdValidationSchema({
|
|
299
|
+
attribute,
|
|
300
|
+
validationSchema: validationSchema,
|
|
301
|
+
label,
|
|
302
|
+
strings,
|
|
303
|
+
});
|
|
304
|
+
break;
|
|
287
305
|
default:
|
|
288
306
|
break;
|
|
289
307
|
}
|
|
@@ -337,6 +355,15 @@ function extendAttributeAttachmentsValidationSchema({ attribute, validationSchem
|
|
|
337
355
|
}
|
|
338
356
|
return validationSchema;
|
|
339
357
|
}
|
|
358
|
+
function extendAttributeIdValidationSchema({ attribute, validationSchema, label, strings, }) {
|
|
359
|
+
if ('guid' in attribute && attribute.guid) {
|
|
360
|
+
validationSchema = validationSchema.matches(guidRegex, `${label}: ${strings.invalidIdFormat}`);
|
|
361
|
+
}
|
|
362
|
+
else if ('objectId' in attribute && attribute.objectId) {
|
|
363
|
+
validationSchema = validationSchema.matches(objectIdRegex, `${label}: ${strings.invalidIdFormat}`);
|
|
364
|
+
}
|
|
365
|
+
return validationSchema;
|
|
366
|
+
}
|
|
340
367
|
exports.generateAttributeValidationSchema = (0, lodash_1.memoize)(function generateAttributeValidationSchema(attribute, language, strings, region) {
|
|
341
368
|
let validationSchema = createAttributeValidationSchema(attribute);
|
|
342
369
|
const label = (0, utils_2.localizedLabel)(language, attribute);
|
|
@@ -7,6 +7,7 @@ export interface FormValidationStringSet {
|
|
|
7
7
|
invalidPhoneNumber: string;
|
|
8
8
|
atLeastOneRowRequired: string;
|
|
9
9
|
fileSizeExceeded: string;
|
|
10
|
+
invalidIdFormat: string;
|
|
10
11
|
}
|
|
11
12
|
export declare const defaultFormValidationStrings: FormValidationStringSet;
|
|
12
13
|
export declare const FormValidationStringContext: import("react").Context<FormValidationStringSet>;
|
|
@@ -12,6 +12,7 @@ exports.defaultFormValidationStrings = {
|
|
|
12
12
|
invalidPhoneNumber: 'Invalid phone number.',
|
|
13
13
|
atLeastOneRowRequired: 'At least one row required.',
|
|
14
14
|
fileSizeExceeded: 'File size exceeded.',
|
|
15
|
+
invalidIdFormat: 'Invalid ID format.',
|
|
15
16
|
};
|
|
16
17
|
exports.FormValidationStringContext = (0, react_1.createContext)(exports.defaultFormValidationStrings);
|
|
17
18
|
function useFormValidationStrings() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/app",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"uuid": "11.0.3",
|
|
37
37
|
"yup": "^1.4.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "1cf9322dda84c1898cc90f1e92278b79ed9f2902"
|
|
40
40
|
}
|