@dhis2/ui-forms 9.11.0 → 9.11.1-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/build/cjs/CheckboxFieldFF/{CheckboxFieldFF.stories.e2e.js → CheckboxFieldFF.e2e.stories.js} +22 -15
- package/build/cjs/CheckboxFieldFF/CheckboxFieldFF.js +2 -12
- package/build/cjs/CheckboxFieldFF/{CheckboxFieldFF.stories.js → CheckboxFieldFF.prod.stories.js} +29 -24
- package/build/cjs/CheckboxFieldFF/features/can_toggle_a_boolean/index.js +0 -1
- package/build/cjs/CheckboxFieldFF/features/can_toggle_a_value/index.js +0 -1
- package/build/cjs/CheckboxFieldFF/features/common/index.js +0 -1
- package/build/cjs/CheckboxFieldFF/features/displays_error/index.js +0 -2
- package/build/cjs/FieldGroupFF/FieldGroupFF.js +1 -10
- package/build/cjs/FieldGroupFF/{FieldGroupFF.stories.js → FieldGroupFF.prod.stories.js} +11 -12
- package/build/cjs/FileInputFieldFF/{FileInputFieldFF.stories.e2e.js → FileInputFieldFF.e2e.stories.js} +45 -56
- package/build/cjs/FileInputFieldFF/FileInputFieldFF.js +2 -19
- package/build/cjs/FileInputFieldFF/{FileInputFieldFF.stories.js → FileInputFieldFF.prod.stories.js} +29 -22
- package/build/cjs/FileInputFieldFF/features/accepts_file/index.js +0 -1
- package/build/cjs/FileInputFieldFF/features/common/index.js +0 -1
- package/build/cjs/FileInputFieldFF/features/displays_error/index.js +0 -1
- package/build/cjs/InputFieldFF/InputFieldFF.e2e.stories.js +30 -0
- package/build/cjs/InputFieldFF/InputFieldFF.js +2 -12
- package/build/cjs/InputFieldFF/{InputFieldFF.stories.js → InputFieldFF.prod.stories.js} +29 -22
- package/build/cjs/InputFieldFF/features/can_set_a_value/index.js +0 -1
- package/build/cjs/InputFieldFF/features/displays_error/index.js +0 -2
- package/build/cjs/MultiSelectFieldFF/{MultiSelectFieldFF.stories.e2e.js → MultiSelectFieldFF.e2e.stories.js} +15 -17
- package/build/cjs/MultiSelectFieldFF/MultiSelectFieldFF.js +3 -15
- package/build/cjs/MultiSelectFieldFF/MultiSelectFieldFF.prod.stories.js +107 -0
- package/build/cjs/MultiSelectFieldFF/features/can_set_a_value/index.js +0 -1
- package/build/cjs/MultiSelectFieldFF/features/common/index.js +1 -2
- package/build/cjs/MultiSelectFieldFF/features/displays_error/index.js +0 -2
- package/build/cjs/RadioFieldFF/RadioFieldFF.e2e.stories.js +45 -0
- package/build/cjs/RadioFieldFF/RadioFieldFF.js +2 -12
- package/build/cjs/RadioFieldFF/{RadioFieldFF.stories.js → RadioFieldFF.prod.stories.js} +29 -16
- package/build/cjs/RadioFieldFF/features/can_set_a_value/index.js +0 -1
- package/build/cjs/RadioFieldFF/features/common/index.js +0 -1
- package/build/cjs/RadioFieldFF/features/displays_error/index.js +0 -2
- package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.e2e.stories.js +39 -0
- package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.js +2 -12
- package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.prod.stories.js +106 -0
- package/build/cjs/SingleSelectFieldFF/features/can_set_a_value/index.js +0 -1
- package/build/cjs/SingleSelectFieldFF/features/common/index.js +0 -1
- package/build/cjs/SingleSelectFieldFF/features/displays_error/index.js +0 -2
- package/build/cjs/SwitchFieldFF/SwitchFieldFF.e2e.stories.js +56 -0
- package/build/cjs/SwitchFieldFF/SwitchFieldFF.js +2 -12
- package/build/cjs/SwitchFieldFF/{SwitchFieldFF.stories.js → SwitchFieldFF.prod.stories.js} +29 -24
- package/build/cjs/SwitchFieldFF/features/can_toggle_a_boolean/index.js +0 -1
- package/build/cjs/SwitchFieldFF/features/can_toggle_a_value/index.js +0 -1
- package/build/cjs/SwitchFieldFF/features/common/index.js +0 -1
- package/build/cjs/SwitchFieldFF/features/displays_error/index.js +0 -2
- package/build/cjs/TextAreaFieldFF/TextAreaFieldFF.e2e.stories.js +30 -0
- package/build/cjs/TextAreaFieldFF/TextAreaFieldFF.js +2 -12
- package/build/cjs/TextAreaFieldFF/{TextAreaFieldFF.stories.js → TextAreaFieldFF.prod.stories.js} +29 -24
- package/build/cjs/TextAreaFieldFF/features/can_set_a_value/index.js +0 -1
- package/build/cjs/TextAreaFieldFF/features/displays_error/index.js +0 -2
- package/build/cjs/__tests__/__snapshots__/index.test.js.snap +3 -0
- package/build/cjs/__tests__/index.test.js +1 -1
- package/build/cjs/formDecorator.js +6 -21
- package/build/cjs/index.js +2 -21
- package/build/cjs/locales/index.js +3 -75
- package/build/cjs/shared/helpers/createBlurHandler.js +0 -3
- package/build/cjs/shared/helpers/createChangeHandler.js +0 -2
- package/build/cjs/shared/helpers/createFocusHandler.js +0 -3
- package/build/cjs/shared/helpers/createSelectChangeHandler.js +0 -2
- package/build/cjs/shared/helpers/createToggleChangeHandler.js +0 -3
- package/build/cjs/shared/helpers/getValidationText.js +0 -6
- package/build/cjs/shared/helpers/hasError.js +0 -2
- package/build/cjs/shared/helpers/isLoading.js +0 -2
- package/build/cjs/shared/helpers/isValid.js +0 -2
- package/build/cjs/shared/helpers.js +0 -9
- package/build/cjs/shared/propTypes.js +7 -20
- package/build/cjs/transformers/arrayWithIdObjects.js +2 -6
- package/build/cjs/transformers/index.js +0 -1
- package/build/cjs/validators/__tests__/alphaNumeric.test.js +0 -2
- package/build/cjs/validators/__tests__/boolean.test.js +0 -2
- package/build/cjs/validators/__tests__/composeValidators.test.js +0 -3
- package/build/cjs/validators/__tests__/createCharacterLengthRange.test.js +6 -6
- package/build/cjs/validators/__tests__/createEqualTo.test.js +0 -3
- package/build/cjs/validators/__tests__/createMaxCharacterLength.test.js +1 -2
- package/build/cjs/validators/__tests__/createMaxNumber.test.js +1 -2
- package/build/cjs/validators/__tests__/createMinCharacterLength.test.js +1 -2
- package/build/cjs/validators/__tests__/createMinNumber.test.js +1 -2
- package/build/cjs/validators/__tests__/createNumberRange.test.js +0 -3
- package/build/cjs/validators/__tests__/createPattern.test.js +1 -3
- package/build/cjs/validators/__tests__/dhis2Password.test.js +0 -2
- package/build/cjs/validators/__tests__/dhis2Username.test.js +0 -2
- package/build/cjs/validators/__tests__/email.test.js +7 -6
- package/build/cjs/validators/__tests__/hasValue.test.js +0 -2
- package/build/cjs/validators/__tests__/integer.test.js +0 -2
- package/build/cjs/validators/__tests__/internationalPhoneNumber.test.js +6 -5
- package/build/cjs/validators/__tests__/number.test.js +0 -2
- package/build/cjs/validators/__tests__/string.test.js +0 -2
- package/build/cjs/validators/__tests__/url.test.js +1 -2
- package/build/cjs/validators/alphaNumeric.js +2 -11
- package/build/cjs/validators/boolean.js +2 -10
- package/build/cjs/validators/composeValidators.js +0 -4
- package/build/cjs/validators/createCharacterLengthRange.js +1 -8
- package/build/cjs/validators/createEqualTo.js +1 -8
- package/build/cjs/validators/createMaxCharacterLength.js +1 -6
- package/build/cjs/validators/createMaxNumber.js +1 -6
- package/build/cjs/validators/createMinCharacterLength.js +1 -6
- package/build/cjs/validators/createMinNumber.js +1 -6
- package/build/cjs/validators/createNumberRange.js +1 -8
- package/build/cjs/validators/createPattern.js +2 -10
- package/build/cjs/validators/dhis2Password.js +6 -28
- package/build/cjs/validators/dhis2Username.js +2 -11
- package/build/cjs/validators/email.js +3 -11
- package/build/cjs/validators/hasValue.js +2 -10
- package/build/cjs/validators/helpers/index.js +1 -16
- package/build/cjs/validators/index.js +0 -20
- package/build/cjs/validators/integer.js +3 -10
- package/build/cjs/validators/internationalPhoneNumber.js +8 -14
- package/build/cjs/validators/number.js +2 -10
- package/build/cjs/validators/string.js +2 -10
- package/build/cjs/validators/test-helpers/index.js +1 -6
- package/build/cjs/validators/url.js +2 -11
- package/build/es/CheckboxFieldFF/{CheckboxFieldFF.stories.e2e.js → CheckboxFieldFF.e2e.stories.js} +14 -7
- package/build/es/CheckboxFieldFF/CheckboxFieldFF.js +1 -3
- package/build/es/CheckboxFieldFF/{CheckboxFieldFF.stories.js → CheckboxFieldFF.prod.stories.js} +29 -3
- package/build/es/FieldGroupFF/FieldGroupFF.js +0 -2
- package/build/es/FieldGroupFF/{FieldGroupFF.stories.js → FieldGroupFF.prod.stories.js} +11 -1
- package/build/es/FileInputFieldFF/{FileInputFieldFF.stories.e2e.js → FileInputFieldFF.e2e.stories.js} +14 -16
- package/build/es/FileInputFieldFF/FileInputFieldFF.js +1 -8
- package/build/es/FileInputFieldFF/{FileInputFieldFF.stories.js → FileInputFieldFF.prod.stories.js} +29 -3
- package/build/es/InputFieldFF/{InputFieldFF.stories.e2e.js → InputFieldFF.e2e.stories.js} +8 -4
- package/build/es/InputFieldFF/InputFieldFF.js +1 -3
- package/build/es/InputFieldFF/{InputFieldFF.stories.js → InputFieldFF.prod.stories.js} +29 -3
- package/build/es/MultiSelectFieldFF/{MultiSelectFieldFF.stories.e2e.js → MultiSelectFieldFF.e2e.stories.js} +7 -7
- package/build/es/MultiSelectFieldFF/MultiSelectFieldFF.js +2 -6
- package/build/es/MultiSelectFieldFF/MultiSelectFieldFF.prod.stories.js +98 -0
- package/build/es/MultiSelectFieldFF/features/common/index.js +1 -1
- package/build/es/RadioFieldFF/{RadioFieldFF.stories.e2e.js → RadioFieldFF.e2e.stories.js} +6 -3
- package/build/es/RadioFieldFF/RadioFieldFF.js +1 -3
- package/build/es/RadioFieldFF/{RadioFieldFF.stories.js → RadioFieldFF.prod.stories.js} +29 -3
- package/build/es/SingleSelectFieldFF/{SingleSelectFieldFF.stories.e2e.js → SingleSelectFieldFF.e2e.stories.js} +10 -6
- package/build/es/SingleSelectFieldFF/SingleSelectFieldFF.js +1 -3
- package/build/es/SingleSelectFieldFF/SingleSelectFieldFF.prod.stories.js +97 -0
- package/build/es/SwitchFieldFF/{SwitchFieldFF.stories.e2e.js → SwitchFieldFF.e2e.stories.js} +14 -7
- package/build/es/SwitchFieldFF/SwitchFieldFF.js +1 -3
- package/build/es/SwitchFieldFF/{SwitchFieldFF.stories.js → SwitchFieldFF.prod.stories.js} +29 -3
- package/build/es/TextAreaFieldFF/{TextAreaFieldFF.stories.e2e.js → TextAreaFieldFF.e2e.stories.js} +8 -4
- package/build/es/TextAreaFieldFF/TextAreaFieldFF.js +1 -3
- package/build/es/TextAreaFieldFF/{TextAreaFieldFF.stories.js → TextAreaFieldFF.prod.stories.js} +29 -3
- package/build/es/__tests__/__snapshots__/index.test.js.snap +3 -0
- package/build/es/__tests__/index.test.js +1 -0
- package/build/es/formDecorator.js +5 -12
- package/build/es/index.js +2 -2
- package/build/es/shared/helpers/createBlurHandler.js +0 -2
- package/build/es/shared/helpers/createChangeHandler.js +0 -2
- package/build/es/shared/helpers/createFocusHandler.js +0 -2
- package/build/es/shared/helpers/createSelectChangeHandler.js +0 -1
- package/build/es/shared/helpers/createToggleChangeHandler.js +0 -2
- package/build/es/shared/helpers/getValidationText.js +0 -5
- package/build/es/shared/helpers/hasError.js +0 -1
- package/build/es/shared/helpers/isLoading.js +0 -1
- package/build/es/shared/helpers/isValid.js +0 -1
- package/build/es/transformers/arrayWithIdObjects.js +0 -2
- package/build/es/validators/__tests__/createCharacterLengthRange.test.js +6 -3
- package/build/es/validators/__tests__/createMaxCharacterLength.test.js +1 -0
- package/build/es/validators/__tests__/createMaxNumber.test.js +1 -0
- package/build/es/validators/__tests__/createMinCharacterLength.test.js +1 -0
- package/build/es/validators/__tests__/createMinNumber.test.js +1 -0
- package/build/es/validators/__tests__/createPattern.test.js +1 -1
- package/build/es/validators/__tests__/email.test.js +7 -4
- package/build/es/validators/__tests__/internationalPhoneNumber.test.js +6 -3
- package/build/es/validators/__tests__/url.test.js +1 -0
- package/build/es/validators/alphaNumeric.js +0 -2
- package/build/es/validators/boolean.js +0 -2
- package/build/es/validators/composeValidators.js +0 -2
- package/build/es/validators/createCharacterLengthRange.js +0 -2
- package/build/es/validators/createEqualTo.js +0 -2
- package/build/es/validators/createMaxCharacterLength.js +0 -2
- package/build/es/validators/createMaxNumber.js +0 -2
- package/build/es/validators/createMinCharacterLength.js +0 -2
- package/build/es/validators/createMinNumber.js +0 -2
- package/build/es/validators/createNumberRange.js +0 -2
- package/build/es/validators/createPattern.js +0 -3
- package/build/es/validators/dhis2Password.js +3 -12
- package/build/es/validators/dhis2Username.js +0 -2
- package/build/es/validators/email.js +1 -2
- package/build/es/validators/hasValue.js +0 -2
- package/build/es/validators/integer.js +3 -4
- package/build/es/validators/internationalPhoneNumber.js +7 -7
- package/build/es/validators/number.js +0 -2
- package/build/es/validators/string.js +0 -2
- package/build/es/validators/test-helpers/index.js +1 -4
- package/build/es/validators/url.js +2 -3
- package/package.json +13 -13
- package/build/cjs/InputFieldFF/InputFieldFF.stories.e2e.js +0 -27
- package/build/cjs/MultiSelectFieldFF/MultiSelectFieldFF.stories.js +0 -91
- package/build/cjs/RadioFieldFF/RadioFieldFF.stories.e2e.js +0 -45
- package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.stories.e2e.js +0 -37
- package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.stories.js +0 -90
- package/build/cjs/SwitchFieldFF/SwitchFieldFF.stories.e2e.js +0 -49
- package/build/cjs/TextAreaFieldFF/TextAreaFieldFF.stories.e2e.js +0 -27
- package/build/es/MultiSelectFieldFF/MultiSelectFieldFF.stories.js +0 -70
- package/build/es/SingleSelectFieldFF/SingleSelectFieldFF.stories.js +0 -69
@@ -57,21 +57,12 @@ Object.defineProperty(exports, "isValid", {
|
|
57
57
|
return _isValid.isValid;
|
58
58
|
}
|
59
59
|
});
|
60
|
-
|
61
60
|
var _createBlurHandler = require("./helpers/createBlurHandler.js");
|
62
|
-
|
63
61
|
var _createChangeHandler = require("./helpers/createChangeHandler.js");
|
64
|
-
|
65
62
|
var _createFocusHandler = require("./helpers/createFocusHandler.js");
|
66
|
-
|
67
63
|
var _createSelectChangeHandler = require("./helpers/createSelectChangeHandler.js");
|
68
|
-
|
69
64
|
var _createToggleChangeHandler = require("./helpers/createToggleChangeHandler.js");
|
70
|
-
|
71
65
|
var _getValidationText = require("./helpers/getValidationText.js");
|
72
|
-
|
73
66
|
var _hasError = require("./helpers/hasError.js");
|
74
|
-
|
75
67
|
var _isLoading = require("./helpers/isLoading.js");
|
76
|
-
|
77
68
|
var _isValid = require("./helpers/isValid.js");
|
@@ -4,50 +4,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.toggleGroupOptionsProp = exports.metaPropType = exports.metaArgType = exports.inputPropType = exports.inputArgType = void 0;
|
7
|
-
|
8
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
const toggleGroupOptionsProp = _propTypes.default.arrayOf(_propTypes.default.shape({
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
9
|
+
const toggleGroupOptionsProp = exports.toggleGroupOptionsProp = _propTypes.default.arrayOf(_propTypes.default.shape({
|
13
10
|
label: _propTypes.default.string.isRequired,
|
14
11
|
value: _propTypes.default.string.isRequired
|
15
12
|
}));
|
16
|
-
|
17
|
-
exports.toggleGroupOptionsProp = toggleGroupOptionsProp;
|
18
|
-
|
19
|
-
const inputPropType = _propTypes.default.shape({
|
13
|
+
const inputPropType = exports.inputPropType = _propTypes.default.shape({
|
20
14
|
name: _propTypes.default.string.isRequired,
|
21
15
|
onChange: _propTypes.default.func.isRequired,
|
22
16
|
value: _propTypes.default.any,
|
23
17
|
onBlur: _propTypes.default.func,
|
24
18
|
onFocus: _propTypes.default.func
|
25
19
|
});
|
26
|
-
|
27
|
-
exports.inputPropType = inputPropType;
|
28
|
-
const inputArgType = {
|
20
|
+
const inputArgType = exports.inputArgType = {
|
29
21
|
table: {
|
30
22
|
type: {
|
31
23
|
summary: '{ name: string (required), onChange: func (required), value: any, onBlur: func, onFocus: func }'
|
32
24
|
}
|
33
25
|
}
|
34
26
|
};
|
35
|
-
exports.
|
36
|
-
|
37
|
-
const metaPropType = _propTypes.default.shape({
|
27
|
+
const metaPropType = exports.metaPropType = _propTypes.default.shape({
|
38
28
|
error: _propTypes.default.string,
|
39
29
|
invalid: _propTypes.default.bool,
|
40
30
|
touched: _propTypes.default.bool,
|
41
31
|
valid: _propTypes.default.bool,
|
42
32
|
validating: _propTypes.default.bool
|
43
33
|
});
|
44
|
-
|
45
|
-
exports.metaPropType = metaPropType;
|
46
|
-
const metaArgType = {
|
34
|
+
const metaArgType = exports.metaArgType = {
|
47
35
|
table: {
|
48
36
|
type: {
|
49
37
|
summary: '{ error: string, invalid: bool, touched: bool, valid: bool, validating: bool }'
|
50
38
|
}
|
51
39
|
}
|
52
|
-
};
|
53
|
-
exports.metaArgType = metaArgType;
|
40
|
+
};
|
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.arrayWithIdObjects = void 0;
|
7
|
-
|
8
7
|
const format = value => !value ? [] : value.map(_ref => {
|
9
8
|
let {
|
10
9
|
id
|
11
10
|
} = _ref;
|
12
11
|
return id;
|
13
12
|
});
|
14
|
-
|
15
13
|
const parse = value => !value || Array.isArray(value) && value.length === 0 ? undefined : value.map(id => ({
|
16
14
|
id
|
17
15
|
}));
|
18
|
-
|
19
|
-
const arrayWithIdObjects = {
|
16
|
+
const arrayWithIdObjects = exports.arrayWithIdObjects = {
|
20
17
|
format,
|
21
18
|
parse
|
22
|
-
};
|
23
|
-
exports.arrayWithIdObjects = arrayWithIdObjects;
|
19
|
+
};
|
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _alphaNumeric = require("../alphaNumeric.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: alphaNumeric', () => {
|
8
6
|
(0, _index.allowsEmptyValues)(_alphaNumeric.alphaNumeric);
|
9
7
|
describe('allows alpha-numeric values', () => {
|
@@ -1,11 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _composeValidators = require("../composeValidators.js");
|
4
|
-
|
5
4
|
var _email = require("../email.js");
|
6
|
-
|
7
5
|
var _hasValue = require("../hasValue.js");
|
8
|
-
|
9
6
|
describe('composeValidators', () => {
|
10
7
|
const validator = (0, _composeValidators.composeValidators)(_hasValue.hasValue, _email.email);
|
11
8
|
it('should return undefined for valid values', () => {
|
@@ -1,11 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _createCharacterLengthRange = require("../createCharacterLengthRange.js");
|
4
|
-
|
5
4
|
var _index = require("../helpers/index.js");
|
6
|
-
|
7
5
|
var _index2 = require("../test-helpers/index.js");
|
8
|
-
|
9
6
|
describe('validator: createCharacterLengthRange', () => {
|
10
7
|
const betweenSixAndTenChars = (0, _createCharacterLengthRange.createCharacterLengthRange)(6, 10);
|
11
8
|
const inValidMsg = 'Please enter between 6 and 10 characters';
|
@@ -28,7 +25,8 @@ describe('validator: createCharacterLengthRange', () => {
|
|
28
25
|
});
|
29
26
|
(0, _index2.allowsEmptyValues)(betweenSixAndTenChars);
|
30
27
|
describe('allows within-range strings', () => {
|
31
|
-
(0, _index2.testValidatorValues)(betweenSixAndTenChars, undefined, ['abcdef',
|
28
|
+
(0, _index2.testValidatorValues)(betweenSixAndTenChars, undefined, ['abcdef',
|
29
|
+
// 6
|
32
30
|
'abcdefgh', 'abcdefghij' // 10
|
33
31
|
]);
|
34
32
|
});
|
@@ -36,8 +34,10 @@ describe('validator: createCharacterLengthRange', () => {
|
|
36
34
|
(0, _index2.testValidatorValues)(betweenSixAndTenChars, inValidMsg, [true, 3, {}, [], () => {}]);
|
37
35
|
});
|
38
36
|
describe('rejects out-of-range strings', () => {
|
39
|
-
(0, _index2.testValidatorValues)(betweenSixAndTenChars, inValidMsg, ['a', 'abcde',
|
40
|
-
|
37
|
+
(0, _index2.testValidatorValues)(betweenSixAndTenChars, inValidMsg, ['a', 'abcde',
|
38
|
+
// 5
|
39
|
+
'abcdefghijk',
|
40
|
+
// 11
|
41
41
|
'abcdefghijklmnopqrstuvw']);
|
42
42
|
});
|
43
43
|
});
|
@@ -1,11 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _createEqualTo = require("../createEqualTo.js");
|
4
|
-
|
5
4
|
var _index = require("../helpers/index.js");
|
6
|
-
|
7
5
|
var _index2 = require("../test-helpers/index.js");
|
8
|
-
|
9
6
|
describe('validator: createEqualTo', () => {
|
10
7
|
const equalToFoo = (0, _createEqualTo.createEqualTo)('foo');
|
11
8
|
it('should throw an error when key is not a string', () => {
|
@@ -1,12 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _createMaxCharacterLength = require("../createMaxCharacterLength.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: createMaxCharacterLength', () => {
|
8
6
|
const maxSixChars = (0, _createMaxCharacterLength.createMaxCharacterLength)(6);
|
9
7
|
const errorMessage = 'Please enter a maximum of 6 characters';
|
8
|
+
|
10
9
|
/*
|
11
10
|
* Since createMaxCharacterLength calls createNumberRange internally
|
12
11
|
* a lot of things have been tested there and here we focus
|
@@ -1,12 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _createMaxNumber = require("../createMaxNumber.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: createMaxNumber', () => {
|
8
6
|
const maxSix = (0, _createMaxNumber.createMaxNumber)(6);
|
9
7
|
const errorMessage = 'Please enter a number with a maximum of 6';
|
8
|
+
|
10
9
|
/*
|
11
10
|
* Since createMaxNumber calls createNumberRange internally
|
12
11
|
* a lot of things have been tested there and here we focus
|
@@ -1,12 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _createMinCharacterLength = require("../createMinCharacterLength.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: createMinCharacterLength', () => {
|
8
6
|
const atLeastSixChars = (0, _createMinCharacterLength.createMinCharacterLength)(6);
|
9
7
|
const errorMessage = 'Please enter at least 6 characters';
|
8
|
+
|
10
9
|
/*
|
11
10
|
* Since createMinCharacterLength calls createCharacterLengthRange internally
|
12
11
|
* a lot of things have been tested there and here we focus
|
@@ -1,12 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _createMinNumber = require("../createMinNumber.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: createMinNumber', () => {
|
8
6
|
const atLeastSix = (0, _createMinNumber.createMinNumber)(6);
|
9
7
|
const errorMessage = 'Please enter a number of at least 6';
|
8
|
+
|
10
9
|
/*
|
11
10
|
* Since createMinNumber calls createNumberRange internally
|
12
11
|
* a lot of things have been tested there and here we focus
|
@@ -1,11 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _createNumberRange = require("../createNumberRange.js");
|
4
|
-
|
5
4
|
var _index = require("../helpers/index.js");
|
6
|
-
|
7
5
|
var _index2 = require("../test-helpers/index.js");
|
8
|
-
|
9
6
|
describe('validator: createNumberRange', () => {
|
10
7
|
const betweenSixAndTen = (0, _createNumberRange.createNumberRange)(6, 10);
|
11
8
|
const errorMessage = 'Number cannot be less than 6 or more than 10';
|
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _createPattern = require("../createPattern.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: createPattern', () => {
|
8
6
|
const pattern = /^test$/;
|
9
7
|
const equalToTestPattern = (0, _createPattern.createPattern)(pattern);
|
@@ -24,7 +22,7 @@ describe('validator: createPattern', () => {
|
|
24
22
|
});
|
25
23
|
it('should return an error string when input does not match the pattern', () => {
|
26
24
|
const escapedRegexString = '/^test$/';
|
27
|
-
const invalidMsg =
|
25
|
+
const invalidMsg = `Please make sure the value of this input matches the pattern ${escapedRegexString}.`;
|
28
26
|
expect(equalToTestPattern('bad input')).toEqual(invalidMsg);
|
29
27
|
});
|
30
28
|
it('should return an custon error string when one was provided and input does not match the pattern', () => {
|
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _dhis2Password = require("../dhis2Password.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: dhis2Password', () => {
|
8
6
|
(0, _index.allowsEmptyValues)(_dhis2Password.dhis2Password);
|
9
7
|
it('should return undefined for a valid password', () => {
|
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _dhis2Username = require("../dhis2Username.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: dhis2Username', () => {
|
8
6
|
(0, _index.allowsEmptyValues)(_dhis2Username.dhis2Username);
|
9
7
|
describe('constrains length of username to between 4 and 255 characters long', () => {
|
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _email = require("../email.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
/*
|
8
6
|
* A comprehensive list technically valid and invalid email addresses was
|
9
7
|
* taken from:
|
@@ -16,14 +14,17 @@ var _index = require("../test-helpers/index.js");
|
|
16
14
|
* I have kept the original list of values and have simply commented out
|
17
15
|
* the ones that are not evaluated correctly by our regex.
|
18
16
|
*/
|
17
|
+
|
19
18
|
describe('validator: email', () => {
|
20
19
|
(0, _index.allowsEmptyValues)(_email.email);
|
21
20
|
describe('allows valid email addresses', () => {
|
22
21
|
/*
|
23
22
|
* Items that have been commented out below are FALSELY REJECTED by the chosen regex
|
24
23
|
*/
|
25
|
-
(0, _index.testValidatorValues)(_email.email, undefined, ['email@example.com', 'firstname.lastname@example.com', 'email@subdomain.example.com', 'firstname+lastname@example.com',
|
24
|
+
(0, _index.testValidatorValues)(_email.email, undefined, ['email@example.com', 'firstname.lastname@example.com', 'email@subdomain.example.com', 'firstname+lastname@example.com',
|
25
|
+
// 'email@123.123.123.123',
|
26
26
|
'email@[123.123.123.123]', '"email"@example.com', '1234567890@example.com', 'email@example-one.com', '_______@example.com', 'email@example.name', 'email@example.museum', 'email@example.co.jp', 'firstname-lastname@example.com'
|
27
|
+
|
27
28
|
/* very strange but technically valid addresses */
|
28
29
|
// 'much."more unusual"@example.com',
|
29
30
|
// 'very.unusual."@".unusual.com@example.com',
|
@@ -40,10 +41,10 @@ describe('validator: email', () => {
|
|
40
41
|
* see https://en.wikipedia.org/wiki/International_email)
|
41
42
|
*/
|
42
43
|
// 'あいうえお@example.com'
|
43
|
-
'email@example.com (Joe Smith)', 'email@example',
|
44
|
+
'email@example.com (Joe Smith)', 'email@example',
|
45
|
+
// 'email@-example.com',
|
44
46
|
// 'email@example.web',
|
45
|
-
'email@111.222.333.44444', 'email@example..com', 'Abc..123@example.com',
|
46
|
-
/* very strange invalid addresses */
|
47
|
+
'email@111.222.333.44444', 'email@example..com', 'Abc..123@example.com', /* very strange invalid addresses */
|
47
48
|
'"(),:;<>[]@example.com', 'just"not"right@example.com', 'this is"really"not\\\\allowed@example.com']);
|
48
49
|
});
|
49
50
|
});
|
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _hasValue = require("../hasValue.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: hasValue', () => {
|
8
6
|
describe('should return undefined for allowed values', () => {
|
9
7
|
(0, _index.testValidatorValues)(_hasValue.hasValue, undefined, ['test', false, true, 0, 1, {}, [], new Date()]);
|
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _integer = require("../integer.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: integer', () => {
|
8
6
|
(0, _index.allowsEmptyValues)(_integer.integer);
|
9
7
|
describe('allows integers and string representations of integers', () => {
|
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _internationalPhoneNumber = require("../internationalPhoneNumber.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: internationalPhoneNumber', () => {
|
8
6
|
(0, _index.allowsEmptyValues)(_internationalPhoneNumber.internationalPhoneNumber);
|
9
7
|
describe('allows valid phone numbers', () => {
|
@@ -13,9 +11,12 @@ describe('validator: internationalPhoneNumber', () => {
|
|
13
11
|
(0, _index.testValidatorValues)(_internationalPhoneNumber.internationalPhoneNumber, _internationalPhoneNumber.invalidInternationalPhoneNumberMessage, [true, 3, {}, [], () => {}]);
|
14
12
|
});
|
15
13
|
describe('rejects invalid phone numbers', () => {
|
16
|
-
(0, _index.testValidatorValues)(_internationalPhoneNumber.internationalPhoneNumber, _internationalPhoneNumber.invalidInternationalPhoneNumberMessage, ['sometext123',
|
17
|
-
|
18
|
-
'+
|
14
|
+
(0, _index.testValidatorValues)(_internationalPhoneNumber.internationalPhoneNumber, _internationalPhoneNumber.invalidInternationalPhoneNumberMessage, ['sometext123',
|
15
|
+
// text
|
16
|
+
'+3172%^$#%*182838485868',
|
17
|
+
// special characters
|
18
|
+
'+31725111889101112131415',
|
19
|
+
// too long
|
19
20
|
'0031_72_5111889' // bad separators
|
20
21
|
]);
|
21
22
|
});
|
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _number = require("../number.js");
|
4
|
-
|
5
4
|
var _index = require("../test-helpers/index.js");
|
6
|
-
|
7
5
|
describe('validator: number', () => {
|
8
6
|
(0, _index.allowsEmptyValues)(_number.number);
|
9
7
|
describe('allows numbers and string representations of numbers', () => {
|
@@ -1,13 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _index = require("../test-helpers/index.js");
|
4
|
-
|
5
4
|
var _url = require("../url.js");
|
6
|
-
|
7
5
|
/**
|
8
6
|
* List of valid and invalid URIs was sourced from
|
9
7
|
* https://formvalidation.io/guide/validators/uri
|
10
8
|
*/
|
9
|
+
|
11
10
|
describe('validator: url', () => {
|
12
11
|
(0, _index.allowsEmptyValues)(_url.url);
|
13
12
|
describe('allows valid URLs', () => {
|
@@ -4,19 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.invalidAlphaNumericMessage = exports.alphaNumeric = void 0;
|
7
|
-
|
8
7
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
9
|
-
|
10
8
|
var _index2 = require("./helpers/index.js");
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
10
|
const ALPHA_NUMERIC_PATTERN = /^[a-z0-9 ]*$/i;
|
15
|
-
|
16
|
-
const invalidAlphaNumericMessage = _index.default.t('Please provide an alpha-numeric value');
|
17
|
-
|
18
|
-
exports.invalidAlphaNumericMessage = invalidAlphaNumericMessage;
|
19
|
-
|
11
|
+
const invalidAlphaNumericMessage = exports.invalidAlphaNumericMessage = _index.default.t('Please provide an alpha-numeric value');
|
20
12
|
const alphaNumeric = value => (0, _index2.isEmpty)(value) || (0, _index2.isString)(value) && ALPHA_NUMERIC_PATTERN.test(value) ? undefined : invalidAlphaNumericMessage;
|
21
|
-
|
22
13
|
exports.alphaNumeric = alphaNumeric;
|
@@ -4,17 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.invalidBooleanMessage = exports.boolean = void 0;
|
7
|
-
|
8
7
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
9
|
-
|
10
8
|
var _index2 = require("./helpers/index.js");
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
const invalidBooleanMessage = _index.default.t('Please provide a boolean value');
|
15
|
-
|
16
|
-
exports.invalidBooleanMessage = invalidBooleanMessage;
|
17
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
10
|
+
const invalidBooleanMessage = exports.invalidBooleanMessage = _index.default.t('Please provide a boolean value');
|
18
11
|
const boolean = value => (0, _index2.isEmpty)(value) || typeof value === 'boolean' ? undefined : invalidBooleanMessage;
|
19
|
-
|
20
12
|
exports.boolean = boolean;
|
@@ -4,19 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.composeValidators = void 0;
|
7
|
-
|
8
7
|
const composeValidators = function () {
|
9
8
|
for (var _len = arguments.length, validators = new Array(_len), _key = 0; _key < _len; _key++) {
|
10
9
|
validators[_key] = arguments[_key];
|
11
10
|
}
|
12
|
-
|
13
11
|
return function () {
|
14
12
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
15
13
|
args[_key2] = arguments[_key2];
|
16
14
|
}
|
17
|
-
|
18
15
|
return validators.reduce((error, validator) => error || validator(...args), undefined);
|
19
16
|
};
|
20
17
|
};
|
21
|
-
|
22
18
|
exports.composeValidators = composeValidators;
|
@@ -4,23 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createCharacterLengthRange = void 0;
|
7
|
-
|
8
7
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
9
|
-
|
10
8
|
var _index2 = require("./helpers/index.js");
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
10
|
const createCharacterLengthRange = (lowerBound, upperBound, customMessage) => {
|
15
11
|
(0, _index2.requireArgument)(lowerBound, 'number');
|
16
12
|
(0, _index2.requireArgument)(upperBound, 'number');
|
17
|
-
|
18
13
|
const errorMessage = customMessage || _index.default.t('Please enter between {{lowerBound}} and {{upperBound}} characters', {
|
19
14
|
lowerBound,
|
20
15
|
upperBound
|
21
16
|
});
|
22
|
-
|
23
17
|
return value => (0, _index2.isEmpty)(value) || (0, _index2.isString)(value) && (0, _index2.isInRange)(lowerBound, upperBound, value.length) ? undefined : errorMessage;
|
24
18
|
};
|
25
|
-
|
26
19
|
exports.createCharacterLengthRange = createCharacterLengthRange;
|
@@ -4,21 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createEqualTo = void 0;
|
7
|
-
|
8
7
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
9
|
-
|
10
8
|
var _index2 = require("./helpers/index.js");
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
10
|
const createEqualTo = (key, description) => {
|
15
11
|
(0, _index2.requireArgument)(key, 'string');
|
16
|
-
|
17
12
|
const errorMessage = _index.default.t('Please make sure the value of this input matches the value in "{{otherField}}".', {
|
18
13
|
otherField: description || key
|
19
14
|
});
|
20
|
-
|
21
15
|
return (value, allValues) => (0, _index2.isEmpty)(value) || value === allValues[key] ? undefined : errorMessage;
|
22
16
|
};
|
23
|
-
|
24
17
|
exports.createEqualTo = createEqualTo;
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createMaxCharacterLength = void 0;
|
7
|
-
|
8
7
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
9
|
-
|
10
8
|
var _createCharacterLengthRange = require("./createCharacterLengthRange.js");
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
10
|
const createMaxCharacterLength = upperBound => (0, _createCharacterLengthRange.createCharacterLengthRange)(0, upperBound, _index.default.t('Please enter a maximum of {{upperBound}} characters', {
|
15
11
|
upperBound
|
16
12
|
}));
|
17
|
-
|
18
13
|
exports.createMaxCharacterLength = createMaxCharacterLength;
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createMaxNumber = void 0;
|
7
|
-
|
8
7
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
9
|
-
|
10
8
|
var _createNumberRange = require("./createNumberRange.js");
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
10
|
const createMaxNumber = upperBound => (0, _createNumberRange.createNumberRange)(-Infinity, upperBound, _index.default.t('Please enter a number with a maximum of {{upperBound}}', {
|
15
11
|
upperBound
|
16
12
|
}));
|
17
|
-
|
18
13
|
exports.createMaxNumber = createMaxNumber;
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createMinCharacterLength = void 0;
|
7
|
-
|
8
7
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
9
|
-
|
10
8
|
var _createCharacterLengthRange = require("./createCharacterLengthRange.js");
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
10
|
const createMinCharacterLength = lowerBound => (0, _createCharacterLengthRange.createCharacterLengthRange)(lowerBound, Infinity, _index.default.t('Please enter at least {{lowerBound}} characters', {
|
15
11
|
lowerBound
|
16
12
|
}));
|
17
|
-
|
18
13
|
exports.createMinCharacterLength = createMinCharacterLength;
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createMinNumber = void 0;
|
7
|
-
|
8
7
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
9
|
-
|
10
8
|
var _createNumberRange = require("./createNumberRange.js");
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
10
|
const createMinNumber = lowerBound => (0, _createNumberRange.createNumberRange)(lowerBound, Infinity, _index.default.t('Please enter a number of at least {{lowerBound}}', {
|
15
11
|
lowerBound
|
16
12
|
}));
|
17
|
-
|
18
13
|
exports.createMinNumber = createMinNumber;
|