@dhis2/ui-forms 8.5.0-beta.1 → 8.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/build/cjs/locales/en/translations.json +1 -1
- package/build/cjs/validators/__tests__/dhis2Username.test.js +7 -7
- package/build/cjs/validators/dhis2Username.js +2 -2
- package/build/es/locales/en/translations.json +1 -1
- package/build/es/validators/__tests__/dhis2Username.test.js +7 -7
- package/build/es/validators/dhis2Username.js +2 -2
- package/package.json +10 -10
@@ -26,5 +26,5 @@
|
|
26
26
|
"Please provide a number": "Please provide a number",
|
27
27
|
"Please provide a string": "Please provide a string",
|
28
28
|
"Please provide a valid url": "Please provide a valid url",
|
29
|
-
"Please provide a username between 4 and 255 characters long and possibly separated by . _
|
29
|
+
"Please provide a username between 4 and 255 characters long and possibly separated by . _ - or @": "Please provide a username between 4 and 255 characters long and possibly separated by . _ - or @"
|
30
30
|
}
|
@@ -10,17 +10,17 @@ describe('validator: dhis2Username', () => {
|
|
10
10
|
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, undefined, ['s'.repeat(4), 's'.repeat(255), 'valid_username']);
|
11
11
|
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['1', 's', 's'.repeat(256)]);
|
12
12
|
});
|
13
|
-
describe('does not allow usernames to start with _, . or @', () => {
|
14
|
-
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['_xxx', '.xxx', '@xxx']);
|
13
|
+
describe('does not allow usernames to start with _, -, . or @', () => {
|
14
|
+
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['_xxx', '-xxx', '.xxx', '@xxx']);
|
15
15
|
});
|
16
|
-
describe('does not allow usernames to end with _, . or @', () => {
|
17
|
-
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['xxx_', 'xxx.', 'xxx@']);
|
16
|
+
describe('does not allow usernames to end with _, -, . or @', () => {
|
17
|
+
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['xxx_', 'xxx-', 'xxx.', 'xxx@']);
|
18
18
|
});
|
19
|
-
describe('does not allow usernames to contain __, .. or @@', () => {
|
20
|
-
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['
|
19
|
+
describe('does not allow usernames to contain __, --, .. or @@', () => {
|
20
|
+
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['xx__xx', 'xx--xx', 'xx..xx', 'xx@@xx']);
|
21
21
|
});
|
22
22
|
describe('constrains characters in usernames to [a-z0-9._@]', () => {
|
23
|
-
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, undefined, ['v@lid_user.name', '123another_v@lid_usern@me', 'UPPER_CASE', 'lower@ca.se']);
|
23
|
+
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, undefined, ['v@lid_user.name', 'v@lid-user.name', '123another_v@lid_usern@me', 'UPPER_CASE', 'lower@ca.se']);
|
24
24
|
(0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['あいうえお', 'some_username^%&*(']);
|
25
25
|
});
|
26
26
|
describe('rejects non-string data types', () => {
|
@@ -11,9 +11,9 @@ var _index2 = require("./helpers/index.js");
|
|
11
11
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
13
|
|
14
|
-
const USERNAME_PATTERN = /^(?=.{4,255}$)(?![_
|
14
|
+
const USERNAME_PATTERN = /^(?=.{4,255}$)(?![_\-.@])(?!.*[_\-.@]{2})[a-zA-Z0-9._\-@]+(?<![_\-.@])$/;
|
15
15
|
|
16
|
-
const invalidUsernameMessage = _index.default.t('Please provide a username between 4 and 255 characters long and possibly separated by . _
|
16
|
+
const invalidUsernameMessage = _index.default.t('Please provide a username between 4 and 255 characters long and possibly separated by . _ - or @');
|
17
17
|
|
18
18
|
exports.invalidUsernameMessage = invalidUsernameMessage;
|
19
19
|
|
@@ -26,5 +26,5 @@
|
|
26
26
|
"Please provide a number": "Please provide a number",
|
27
27
|
"Please provide a string": "Please provide a string",
|
28
28
|
"Please provide a valid url": "Please provide a valid url",
|
29
|
-
"Please provide a username between 4 and 255 characters long and possibly separated by . _
|
29
|
+
"Please provide a username between 4 and 255 characters long and possibly separated by . _ - or @": "Please provide a username between 4 and 255 characters long and possibly separated by . _ - or @"
|
30
30
|
}
|
@@ -6,17 +6,17 @@ describe('validator: dhis2Username', () => {
|
|
6
6
|
testValidatorValues(dhis2Username, undefined, ['s'.repeat(4), 's'.repeat(255), 'valid_username']);
|
7
7
|
testValidatorValues(dhis2Username, invalidUsernameMessage, ['1', 's', 's'.repeat(256)]);
|
8
8
|
});
|
9
|
-
describe('does not allow usernames to start with _, . or @', () => {
|
10
|
-
testValidatorValues(dhis2Username, invalidUsernameMessage, ['_xxx', '.xxx', '@xxx']);
|
9
|
+
describe('does not allow usernames to start with _, -, . or @', () => {
|
10
|
+
testValidatorValues(dhis2Username, invalidUsernameMessage, ['_xxx', '-xxx', '.xxx', '@xxx']);
|
11
11
|
});
|
12
|
-
describe('does not allow usernames to end with _, . or @', () => {
|
13
|
-
testValidatorValues(dhis2Username, invalidUsernameMessage, ['xxx_', 'xxx.', 'xxx@']);
|
12
|
+
describe('does not allow usernames to end with _, -, . or @', () => {
|
13
|
+
testValidatorValues(dhis2Username, invalidUsernameMessage, ['xxx_', 'xxx-', 'xxx.', 'xxx@']);
|
14
14
|
});
|
15
|
-
describe('does not allow usernames to contain __, .. or @@', () => {
|
16
|
-
testValidatorValues(dhis2Username, invalidUsernameMessage, ['
|
15
|
+
describe('does not allow usernames to contain __, --, .. or @@', () => {
|
16
|
+
testValidatorValues(dhis2Username, invalidUsernameMessage, ['xx__xx', 'xx--xx', 'xx..xx', 'xx@@xx']);
|
17
17
|
});
|
18
18
|
describe('constrains characters in usernames to [a-z0-9._@]', () => {
|
19
|
-
testValidatorValues(dhis2Username, undefined, ['v@lid_user.name', '123another_v@lid_usern@me', 'UPPER_CASE', 'lower@ca.se']);
|
19
|
+
testValidatorValues(dhis2Username, undefined, ['v@lid_user.name', 'v@lid-user.name', '123another_v@lid_usern@me', 'UPPER_CASE', 'lower@ca.se']);
|
20
20
|
testValidatorValues(dhis2Username, invalidUsernameMessage, ['あいうえお', 'some_username^%&*(']);
|
21
21
|
});
|
22
22
|
describe('rejects non-string data types', () => {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import i18n from '../locales/index.js';
|
2
2
|
import { isEmpty, isString } from './helpers/index.js';
|
3
|
-
const USERNAME_PATTERN = /^(?=.{4,255}$)(?![_
|
4
|
-
const invalidUsernameMessage = i18n.t('Please provide a username between 4 and 255 characters long and possibly separated by . _
|
3
|
+
const USERNAME_PATTERN = /^(?=.{4,255}$)(?![_\-.@])(?!.*[_\-.@]{2})[a-zA-Z0-9._\-@]+(?<![_\-.@])$/;
|
4
|
+
const invalidUsernameMessage = i18n.t('Please provide a username between 4 and 255 characters long and possibly separated by . _ - or @');
|
5
5
|
|
6
6
|
const dhis2Username = value => isEmpty(value) || isString(value) && USERNAME_PATTERN.test(value) ? undefined : invalidUsernameMessage;
|
7
7
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dhis2/ui-forms",
|
3
|
-
"version": "8.5.0
|
3
|
+
"version": "8.5.0",
|
4
4
|
"main": "./build/cjs/index.js",
|
5
5
|
"module": "./build/es/index.js",
|
6
6
|
"sideEffects": [
|
@@ -34,15 +34,15 @@
|
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
36
|
"@dhis2/prop-types": "^3.1.2",
|
37
|
-
"@dhis2-ui/button": "8.5.0
|
38
|
-
"@dhis2-ui/checkbox": "8.5.0
|
39
|
-
"@dhis2-ui/field": "8.5.0
|
40
|
-
"@dhis2-ui/file-input": "8.5.0
|
41
|
-
"@dhis2-ui/input": "8.5.0
|
42
|
-
"@dhis2-ui/radio": "8.5.0
|
43
|
-
"@dhis2-ui/select": "8.5.0
|
44
|
-
"@dhis2-ui/switch": "8.5.0
|
45
|
-
"@dhis2-ui/text-area": "8.5.0
|
37
|
+
"@dhis2-ui/button": "8.5.0",
|
38
|
+
"@dhis2-ui/checkbox": "8.5.0",
|
39
|
+
"@dhis2-ui/field": "8.5.0",
|
40
|
+
"@dhis2-ui/file-input": "8.5.0",
|
41
|
+
"@dhis2-ui/input": "8.5.0",
|
42
|
+
"@dhis2-ui/radio": "8.5.0",
|
43
|
+
"@dhis2-ui/select": "8.5.0",
|
44
|
+
"@dhis2-ui/switch": "8.5.0",
|
45
|
+
"@dhis2-ui/text-area": "8.5.0",
|
46
46
|
"classnames": "^2.3.1",
|
47
47
|
"final-form": "^4.20.2",
|
48
48
|
"prop-types": "^15.7.2",
|