@dev-crew-berlin/enter-js-utils 0.6.1 → 0.6.2
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/models/_helpers.js +1 -1
- package/dist/models/field.js +11 -11
- package/package.json +1 -1
package/dist/models/_helpers.js
CHANGED
|
@@ -69,7 +69,7 @@ export function parseTimestamp(value) {
|
|
|
69
69
|
}
|
|
70
70
|
export function maybe(validator, defaultValue = null) {
|
|
71
71
|
return value => {
|
|
72
|
-
if (value === null) return success(defaultValue);
|
|
72
|
+
if (value === null || value === undefined) return success(defaultValue);
|
|
73
73
|
return validator(value);
|
|
74
74
|
};
|
|
75
75
|
}
|
package/dist/models/field.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { array, object, string, enumerate, boolean,
|
|
1
|
+
import { array, object, string, enumerate, boolean, union, number } from 'fefe';
|
|
2
2
|
import { apiValidator } from '../lib';
|
|
3
3
|
import { dictionary, maybe } from './_helpers';
|
|
4
4
|
const basicFieldProps = {
|
|
5
5
|
name: string({
|
|
6
6
|
minLength: 1
|
|
7
7
|
}),
|
|
8
|
-
title:
|
|
9
|
-
info:
|
|
10
|
-
required:
|
|
11
|
-
if:
|
|
12
|
-
class:
|
|
8
|
+
title: maybe(union(string(), dictionary(string()))),
|
|
9
|
+
info: maybe(union(string(), dictionary(string()))),
|
|
10
|
+
required: maybe(boolean(), false),
|
|
11
|
+
if: maybe(string()),
|
|
12
|
+
class: maybe(string())
|
|
13
13
|
};
|
|
14
14
|
const staticField = object({
|
|
15
15
|
type: enumerate('static'),
|
|
@@ -46,7 +46,7 @@ const checkboxField = object({
|
|
|
46
46
|
...basicFieldProps,
|
|
47
47
|
items: array(object({
|
|
48
48
|
name: union(string(), dictionary(string())),
|
|
49
|
-
value:
|
|
49
|
+
value: maybe(string())
|
|
50
50
|
}))
|
|
51
51
|
}, {
|
|
52
52
|
allowExcessProperties: true
|
|
@@ -54,7 +54,7 @@ const checkboxField = object({
|
|
|
54
54
|
const singleCheckboxField = object({
|
|
55
55
|
type: enumerate('checkbox'),
|
|
56
56
|
...basicFieldProps,
|
|
57
|
-
value:
|
|
57
|
+
value: maybe(number(), 0)
|
|
58
58
|
}, {
|
|
59
59
|
allowExcessProperties: true
|
|
60
60
|
});
|
|
@@ -63,7 +63,7 @@ const radioField = object({
|
|
|
63
63
|
...basicFieldProps,
|
|
64
64
|
items: array(object({
|
|
65
65
|
name: union(string(), dictionary(string())),
|
|
66
|
-
value:
|
|
66
|
+
value: maybe(string())
|
|
67
67
|
}))
|
|
68
68
|
}, {
|
|
69
69
|
allowExcessProperties: true
|
|
@@ -71,7 +71,7 @@ const radioField = object({
|
|
|
71
71
|
const singleRadioField = object({
|
|
72
72
|
type: enumerate('radiobutton'),
|
|
73
73
|
...basicFieldProps,
|
|
74
|
-
itemval:
|
|
74
|
+
itemval: maybe(string())
|
|
75
75
|
}, {
|
|
76
76
|
allowExcessProperties: true
|
|
77
77
|
});
|
|
@@ -80,7 +80,7 @@ const selectField = object({
|
|
|
80
80
|
...basicFieldProps,
|
|
81
81
|
items: array(object({
|
|
82
82
|
name: union(string(), dictionary(string())),
|
|
83
|
-
value:
|
|
83
|
+
value: maybe(string())
|
|
84
84
|
}))
|
|
85
85
|
}, {
|
|
86
86
|
allowExcessProperties: true
|