inibase 1.0.0-rc.71 → 1.0.0-rc.72
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/utils.js +18 -7
- package/package.json +1 -1
package/dist/utils.js
CHANGED
|
@@ -243,17 +243,28 @@ export const detectFieldType = (input, availableTypes) => {
|
|
|
243
243
|
export const validateFieldType = (value, fieldType, fieldChildrenType) => {
|
|
244
244
|
if (value === null)
|
|
245
245
|
return true;
|
|
246
|
-
if (Array.isArray(fieldType))
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
if (Array.isArray(fieldType)) {
|
|
247
|
+
const detectedFieldType = detectFieldType(value, fieldType);
|
|
248
|
+
if (!detectedFieldType)
|
|
249
|
+
return false;
|
|
250
|
+
fieldType = detectedFieldType;
|
|
251
|
+
}
|
|
252
|
+
if (fieldType === "array" && fieldChildrenType)
|
|
253
|
+
return value.every((v) => {
|
|
254
|
+
let _fieldChildrenType = fieldChildrenType;
|
|
255
|
+
if (Array.isArray(_fieldChildrenType)) {
|
|
256
|
+
const detectedFieldType = detectFieldType(v, _fieldChildrenType);
|
|
257
|
+
if (!detectedFieldType)
|
|
258
|
+
return false;
|
|
259
|
+
_fieldChildrenType = detectedFieldType;
|
|
260
|
+
}
|
|
261
|
+
return validateFieldType(v, _fieldChildrenType);
|
|
262
|
+
});
|
|
252
263
|
switch (fieldType) {
|
|
253
264
|
case "string":
|
|
254
265
|
return isString(value);
|
|
255
266
|
case "password":
|
|
256
|
-
return
|
|
267
|
+
return !Array.isArray(value) && !isObject(value); // accept
|
|
257
268
|
case "number":
|
|
258
269
|
return isNumber(value);
|
|
259
270
|
case "html":
|