@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.
@@ -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
  }
@@ -1,15 +1,15 @@
1
- import { array, object, string, enumerate, boolean, defaultTo, union, number } from 'fefe';
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: defaultTo(maybe(union(string(), dictionary(string()))), null),
9
- info: defaultTo(maybe(union(string(), dictionary(string()))), null),
10
- required: defaultTo(boolean(), false),
11
- if: defaultTo(maybe(string()), null),
12
- class: defaultTo(maybe(string()), null)
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: defaultTo(maybe(string()), null)
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: defaultTo(number(), 0)
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: defaultTo(maybe(string()), null)
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: defaultTo(maybe(string()), null)
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: defaultTo(maybe(string()), null)
83
+ value: maybe(string())
84
84
  }))
85
85
  }, {
86
86
  allowExcessProperties: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-crew-berlin/enter-js-utils",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "utils such as vaildation and other helpers to work with data from the enter app",
5
5
  "files": [
6
6
  "dist",