@dhis2/ui-forms 7.11.2 → 7.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. package/build/cjs/locales/ar/translations.json +1 -1
  2. package/build/cjs/locales/ar_IQ/translations.json +1 -1
  3. package/build/cjs/locales/ckb/translations.json +1 -1
  4. package/build/cjs/locales/cs/translations.json +1 -1
  5. package/build/cjs/locales/da/translations.json +1 -1
  6. package/build/cjs/locales/en/translations.json +29 -29
  7. package/build/cjs/locales/es/translations.json +1 -1
  8. package/build/cjs/locales/fr/translations.json +1 -1
  9. package/build/cjs/locales/id/translations.json +1 -1
  10. package/build/cjs/locales/km/translations.json +1 -1
  11. package/build/cjs/locales/lo/translations.json +1 -1
  12. package/build/cjs/locales/my/translations.json +1 -1
  13. package/build/cjs/locales/nb/translations.json +1 -1
  14. package/build/cjs/locales/prs/translations.json +1 -1
  15. package/build/cjs/locales/ps/translations.json +1 -1
  16. package/build/cjs/locales/pt/translations.json +1 -1
  17. package/build/cjs/locales/pt_BR/translations.json +1 -1
  18. package/build/cjs/locales/ru/translations.json +1 -1
  19. package/build/cjs/locales/sv/translations.json +1 -1
  20. package/build/cjs/locales/tet/translations.json +1 -1
  21. package/build/cjs/locales/tg/translations.json +1 -1
  22. package/build/cjs/locales/uk/translations.json +1 -1
  23. package/build/cjs/locales/ur/translations.json +1 -1
  24. package/build/cjs/locales/uz/translations.json +1 -1
  25. package/build/cjs/locales/uz_Latn/translations.json +1 -1
  26. package/build/cjs/locales/vi/translations.json +1 -1
  27. package/build/cjs/locales/zh/translations.json +1 -1
  28. package/build/cjs/locales/zh_CN/translations.json +1 -1
  29. package/build/cjs/validators/__tests__/dhis2Username.test.js +17 -9
  30. package/build/cjs/validators/dhis2Username.js +4 -2
  31. package/build/es/locales/ar/translations.json +1 -1
  32. package/build/es/locales/ar_IQ/translations.json +1 -1
  33. package/build/es/locales/ckb/translations.json +1 -1
  34. package/build/es/locales/cs/translations.json +1 -1
  35. package/build/es/locales/da/translations.json +1 -1
  36. package/build/es/locales/en/translations.json +29 -29
  37. package/build/es/locales/es/translations.json +1 -1
  38. package/build/es/locales/fr/translations.json +1 -1
  39. package/build/es/locales/id/translations.json +1 -1
  40. package/build/es/locales/km/translations.json +1 -1
  41. package/build/es/locales/lo/translations.json +1 -1
  42. package/build/es/locales/my/translations.json +1 -1
  43. package/build/es/locales/nb/translations.json +1 -1
  44. package/build/es/locales/prs/translations.json +1 -1
  45. package/build/es/locales/ps/translations.json +1 -1
  46. package/build/es/locales/pt/translations.json +1 -1
  47. package/build/es/locales/pt_BR/translations.json +1 -1
  48. package/build/es/locales/ru/translations.json +1 -1
  49. package/build/es/locales/sv/translations.json +1 -1
  50. package/build/es/locales/tet/translations.json +1 -1
  51. package/build/es/locales/tg/translations.json +1 -1
  52. package/build/es/locales/uk/translations.json +1 -1
  53. package/build/es/locales/ur/translations.json +1 -1
  54. package/build/es/locales/uz/translations.json +1 -1
  55. package/build/es/locales/uz_Latn/translations.json +1 -1
  56. package/build/es/locales/vi/translations.json +1 -1
  57. package/build/es/locales/zh/translations.json +1 -1
  58. package/build/es/locales/zh_CN/translations.json +1 -1
  59. package/build/es/validators/__tests__/dhis2Username.test.js +17 -9
  60. package/build/es/validators/dhis2Username.js +3 -2
  61. package/package.json +10 -10
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "يجب أن تحتوي كلمة المرور على حرف كبير واحد على الأقل",
21
21
  "Password should contain at least one number": "يجب أن تحتوي كلمة المرور على رقم واحد على الأقل",
22
22
  "Password should have at least one special character": "يجب أن تحتوي كلمة المرور على رمز واحد على الأقل",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "يرجى ادخال صيغة بريد الكتروني سليمة",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "من فضلك ادخل صيغة بريد الكتروني سليمة",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "تکایە ئیمەیڵێکی درووست بنووسە",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Heslo by mělo obsahovat alespoň jedno VELKÉ písmeno",
21
21
  "Password should contain at least one number": "Heslo by mělo obsahovat alespoň jedno číslo",
22
22
  "Password should have at least one special character": "Heslo by mělo mít alespoň jeden speciální znak",
23
- "Please provide a username between 1 and 255 characters": "Zadejte prosím uživatelské jméno mezi 1 a 255 znaky",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Uveďte platnou e-mailovou adresu",
25
25
  "Please provide a value": "Zadejte prosím hodnotu",
26
26
  "Please provide a round number without decimals": "Uveďte prosím zaokrouhlené číslo bez desetinných míst",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -1,31 +1,31 @@
1
1
  {
2
- "Upload file": "",
3
- "Upload files": "",
4
- "Remove": "",
5
- "No file(s) selected yet": "",
6
- "Please provide an alpha-numeric value": "",
7
- "Please provide a boolean value": "",
8
- "Please enter between {{lowerBound}} and {{upperBound}} characters": "",
9
- "Please make sure the value of this input matches the value in \"{{otherField}}\".": "",
10
- "Please enter a maximum of {{upperBound}} characters": "",
11
- "Please enter a number with a maximum of {{upperBound}}": "",
12
- "Please enter at least {{lowerBound}} characters": "",
13
- "Please enter a number of at least {{lowerBound}}": "",
14
- "Number cannot be less than {{lowerBound}} or more than {{upperBound}}": "",
15
- "Please make sure the value of this input matches the pattern {{patternString}}.": "",
16
- "Password should be a string": "",
17
- "Password should be at least 8 characters long": "",
18
- "Password should be no longer than 34 characters": "",
19
- "Password should contain at least one lowercase letter": "",
20
- "Password should contain at least one UPPERCASE letter": "",
21
- "Password should contain at least one number": "",
22
- "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
24
- "Please provide a valid email address": "",
25
- "Please provide a value": "",
26
- "Please provide a round number without decimals": "",
27
- "Please provide a valid international phone number.": "",
28
- "Please provide a number": "",
29
- "Please provide a string": "",
30
- "Please provide a valid url": ""
2
+ "Upload file": "Upload file",
3
+ "Upload files": "Upload files",
4
+ "Remove": "Remove",
5
+ "No file(s) selected yet": "No file(s) selected yet",
6
+ "Please provide an alpha-numeric value": "Please provide an alpha-numeric value",
7
+ "Please provide a boolean value": "Please provide a boolean value",
8
+ "Please enter between {{lowerBound}} and {{upperBound}} characters": "Please enter between {{lowerBound}} and {{upperBound}} characters",
9
+ "Please make sure the value of this input matches the value in \"{{otherField}}\".": "Please make sure the value of this input matches the value in \"{{otherField}}\".",
10
+ "Please enter a maximum of {{upperBound}} characters": "Please enter a maximum of {{upperBound}} characters",
11
+ "Please enter a number with a maximum of {{upperBound}}": "Please enter a number with a maximum of {{upperBound}}",
12
+ "Please enter at least {{lowerBound}} characters": "Please enter at least {{lowerBound}} characters",
13
+ "Please enter a number of at least {{lowerBound}}": "Please enter a number of at least {{lowerBound}}",
14
+ "Number cannot be less than {{lowerBound}} or more than {{upperBound}}": "Number cannot be less than {{lowerBound}} or more than {{upperBound}}",
15
+ "Please make sure the value of this input matches the pattern {{patternString}}.": "Please make sure the value of this input matches the pattern {{patternString}}.",
16
+ "Password should be a string": "Password should be a string",
17
+ "Password should be at least 8 characters long": "Password should be at least 8 characters long",
18
+ "Password should be no longer than 34 characters": "Password should be no longer than 34 characters",
19
+ "Password should contain at least one lowercase letter": "Password should contain at least one lowercase letter",
20
+ "Password should contain at least one UPPERCASE letter": "Password should contain at least one UPPERCASE letter",
21
+ "Password should contain at least one number": "Password should contain at least one number",
22
+ "Password should have at least one special character": "Password should have at least one special character",
23
+ "Please provide a username between 4 and 255 characters": "Please provide a username between 4 and 255 characters",
24
+ "Please provide a valid email address": "Please provide a valid email address",
25
+ "Please provide a value": "Please provide a value",
26
+ "Please provide a round number without decimals": "Please provide a round number without decimals",
27
+ "Please provide a valid international phone number.": "Please provide a valid international phone number.",
28
+ "Please provide a number": "Please provide a number",
29
+ "Please provide a string": "Please provide a string",
30
+ "Please provide a valid url": "Please provide a valid url"
31
31
  }
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "La contraseña debe contener al menos una letra MAYÚSCULA",
21
21
  "Password should contain at least one number": "La contraseña debe contener al menos un número",
22
22
  "Password should have at least one special character": "La contraseña debe tener al menos un carácter especial",
23
- "Please provide a username between 1 and 255 characters": "Proporcione un usuario de entre 1 y 255 caracteres",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Por favor proporcione un correo electrónico válido",
25
25
  "Please provide a value": "Proporcione un valor",
26
26
  "Please provide a round number without decimals": "Por favor, proporcione un número redondo sin decimales",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Le mot de passe doit contenir au moins une lettre MAJUSCULE",
21
21
  "Password should contain at least one number": "Le mot de passe doit contenir au moins un chiffre",
22
22
  "Password should have at least one special character": "Le mot de passe doit avoir au moins un caractère spécial",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Veuillez saisir une adresse email valide",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Passordet må inneholdet minst en STOR bokstav",
21
21
  "Password should contain at least one number": "Passord må inneholde minst et siffer",
22
22
  "Password should have at least one special character": "Passordet skal ha minst ett spesialtegn",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Vennligst fyll ut en gyldig e-postadresse",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "A senha deve conter pelo menos uma letra MAIÚSCULA",
21
21
  "Password should contain at least one number": "A senha deve conter pelo menos um número",
22
22
  "Password should have at least one special character": "A senha deve ter pelo menos um caractere especial",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Por favor forneça um endereço de e-mail válido",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Пароль должен содержать хотя бы одну ЗАГЛАВНУЮ букву",
21
21
  "Password should contain at least one number": "Пароль должен содержать хотя бы одну цифру",
22
22
  "Password should have at least one special character": "В пароле должен быть хотя бы один специальный символ",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Введите правильный адрес электронной почты",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Lösenordet ska innehålla minst en versal bokstav",
21
21
  "Password should contain at least one number": "Lösenordet måste innehålla minst en siffra",
22
22
  "Password should have at least one special character": "Lösenordet ska ha minst ett specialtecken",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Ange en giltig epost adress",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Пароль таркибида камида 1 та БОШ ҳарф бўлиши лозим",
21
21
  "Password should contain at least one number": "Пароль таркибида камида 1 та рақам бўлиши лозим",
22
22
  "Password should have at least one special character": "Пароль таркибида камида 1 та махсус белги бўлиши лозим",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Илтимос, амалдаги е-почта манзилини кўрсатинг",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Parol tarkibida kamida 1 ta BOSh harf boʼlishi lozim",
21
21
  "Password should contain at least one number": "Parol tarkibida kamida 1 ta raqam boʼlishi lozim",
22
22
  "Password should have at least one special character": "Parol tarkibida kamida 1 ta maxsus belgi boʼlishi lozim",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Iltimos, amaldagi ye-pochta manzilini koʼrsating",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Mật khẩu phải chứa ít nhất một chữ cái viết hoa",
21
21
  "Password should contain at least one number": "Mật khẩu phải chứa ít nhất một số",
22
22
  "Password should have at least one special character": "Mật khẩu phải có ít nhất một ký tự đặc biệt",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Vui lòng cung cấp một địa chỉ email hợp lệ",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "口令至少包括一个大写字母",
21
21
  "Password should contain at least one number": "口令至少包括应该数字",
22
22
  "Password should have at least one special character": "口令至少包括一个特殊字符",
23
- "Please provide a username between 1 and 255 characters": "请提供 1 到 255 个字符之间的用户名",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "有效的邮箱",
25
25
  "Please provide a value": "请提供值",
26
26
  "Please provide a round number without decimals": "请提供一个没有小数的整数",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "口令至少包括一个大写字母",
21
21
  "Password should contain at least one number": "口令至少包括应该数字",
22
22
  "Password should have at least one special character": "口令至少包括一个特殊字符",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "有效的邮箱",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -6,16 +6,24 @@ var _index = require("../test-helpers/index.js");
6
6
 
7
7
  describe('validator: dhis2Username', () => {
8
8
  (0, _index.allowsEmptyValues)(_dhis2Username.dhis2Username);
9
- describe('allows all sorts of strings between 1 and 255 characters long', () => {
10
- (0, _index.testValidatorValues)(_dhis2Username.dhis2Username, undefined, ['electricchicken', '1', //1
11
- 'sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss', //255
12
- 'some_username^%&*(', 'あいうえお']);
9
+ describe('constrains length of username to between 4 and 255 characters long', () => {
10
+ (0, _index.testValidatorValues)(_dhis2Username.dhis2Username, undefined, ['s'.repeat(4), 's'.repeat(255), 'valid_username']);
11
+ (0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['1', 's', 's'.repeat(256)]);
13
12
  });
14
- describe('rejects other data types', () => {
15
- (0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, [1, true, {}, [], () => {}]);
13
+ describe('does not allow usernames to start with _, . or @', () => {
14
+ (0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['_xxx', '.xxx', '@xxx']);
15
+ });
16
+ describe('does not allow usernames to end with _, . or @', () => {
17
+ (0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['xxx_', 'xxx.', 'xxx@']);
18
+ });
19
+ describe('does not allow usernames to contain __, .. or @@', () => {
20
+ (0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['__xx', '..xx', '@@xx']);
16
21
  });
17
- describe('values that are too long', () => {
18
- (0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss' //256
19
- ]);
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']);
24
+ (0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, ['あいうえお', 'some_username^%&*(']);
25
+ });
26
+ describe('rejects non-string data types', () => {
27
+ (0, _index.testValidatorValues)(_dhis2Username.dhis2Username, _dhis2Username.invalidUsernameMessage, [1, true, {}, [], () => {}]);
20
28
  });
21
29
  });
@@ -11,10 +11,12 @@ var _index2 = require("./helpers/index.js");
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- const invalidUsernameMessage = _index.default.t('Please provide a username between 1 and 255 characters');
14
+ const USERNAME_PATTERN = /^(?=.{4,255}$)(?![_.@])(?!.*[_.@]{2})[a-z0-9._@]+(?<![_.@])$/;
15
+
16
+ const invalidUsernameMessage = _index.default.t('Please provide a username between 4 and 255 characters');
15
17
 
16
18
  exports.invalidUsernameMessage = invalidUsernameMessage;
17
19
 
18
- const dhis2Username = value => (0, _index2.isEmpty)(value) || (0, _index2.isString)(value) && value.length >= 1 && value.length <= 255 ? undefined : invalidUsernameMessage;
20
+ const dhis2Username = value => (0, _index2.isEmpty)(value) || (0, _index2.isString)(value) && USERNAME_PATTERN.test(value) ? undefined : invalidUsernameMessage;
19
21
 
20
22
  exports.dhis2Username = dhis2Username;
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "يجب أن تحتوي كلمة المرور على حرف كبير واحد على الأقل",
21
21
  "Password should contain at least one number": "يجب أن تحتوي كلمة المرور على رقم واحد على الأقل",
22
22
  "Password should have at least one special character": "يجب أن تحتوي كلمة المرور على رمز واحد على الأقل",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "يرجى ادخال صيغة بريد الكتروني سليمة",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "من فضلك ادخل صيغة بريد الكتروني سليمة",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "تکایە ئیمەیڵێکی درووست بنووسە",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Heslo by mělo obsahovat alespoň jedno VELKÉ písmeno",
21
21
  "Password should contain at least one number": "Heslo by mělo obsahovat alespoň jedno číslo",
22
22
  "Password should have at least one special character": "Heslo by mělo mít alespoň jeden speciální znak",
23
- "Please provide a username between 1 and 255 characters": "Zadejte prosím uživatelské jméno mezi 1 a 255 znaky",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Uveďte platnou e-mailovou adresu",
25
25
  "Please provide a value": "Zadejte prosím hodnotu",
26
26
  "Please provide a round number without decimals": "Uveďte prosím zaokrouhlené číslo bez desetinných míst",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -1,31 +1,31 @@
1
1
  {
2
- "Upload file": "",
3
- "Upload files": "",
4
- "Remove": "",
5
- "No file(s) selected yet": "",
6
- "Please provide an alpha-numeric value": "",
7
- "Please provide a boolean value": "",
8
- "Please enter between {{lowerBound}} and {{upperBound}} characters": "",
9
- "Please make sure the value of this input matches the value in \"{{otherField}}\".": "",
10
- "Please enter a maximum of {{upperBound}} characters": "",
11
- "Please enter a number with a maximum of {{upperBound}}": "",
12
- "Please enter at least {{lowerBound}} characters": "",
13
- "Please enter a number of at least {{lowerBound}}": "",
14
- "Number cannot be less than {{lowerBound}} or more than {{upperBound}}": "",
15
- "Please make sure the value of this input matches the pattern {{patternString}}.": "",
16
- "Password should be a string": "",
17
- "Password should be at least 8 characters long": "",
18
- "Password should be no longer than 34 characters": "",
19
- "Password should contain at least one lowercase letter": "",
20
- "Password should contain at least one UPPERCASE letter": "",
21
- "Password should contain at least one number": "",
22
- "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
24
- "Please provide a valid email address": "",
25
- "Please provide a value": "",
26
- "Please provide a round number without decimals": "",
27
- "Please provide a valid international phone number.": "",
28
- "Please provide a number": "",
29
- "Please provide a string": "",
30
- "Please provide a valid url": ""
2
+ "Upload file": "Upload file",
3
+ "Upload files": "Upload files",
4
+ "Remove": "Remove",
5
+ "No file(s) selected yet": "No file(s) selected yet",
6
+ "Please provide an alpha-numeric value": "Please provide an alpha-numeric value",
7
+ "Please provide a boolean value": "Please provide a boolean value",
8
+ "Please enter between {{lowerBound}} and {{upperBound}} characters": "Please enter between {{lowerBound}} and {{upperBound}} characters",
9
+ "Please make sure the value of this input matches the value in \"{{otherField}}\".": "Please make sure the value of this input matches the value in \"{{otherField}}\".",
10
+ "Please enter a maximum of {{upperBound}} characters": "Please enter a maximum of {{upperBound}} characters",
11
+ "Please enter a number with a maximum of {{upperBound}}": "Please enter a number with a maximum of {{upperBound}}",
12
+ "Please enter at least {{lowerBound}} characters": "Please enter at least {{lowerBound}} characters",
13
+ "Please enter a number of at least {{lowerBound}}": "Please enter a number of at least {{lowerBound}}",
14
+ "Number cannot be less than {{lowerBound}} or more than {{upperBound}}": "Number cannot be less than {{lowerBound}} or more than {{upperBound}}",
15
+ "Please make sure the value of this input matches the pattern {{patternString}}.": "Please make sure the value of this input matches the pattern {{patternString}}.",
16
+ "Password should be a string": "Password should be a string",
17
+ "Password should be at least 8 characters long": "Password should be at least 8 characters long",
18
+ "Password should be no longer than 34 characters": "Password should be no longer than 34 characters",
19
+ "Password should contain at least one lowercase letter": "Password should contain at least one lowercase letter",
20
+ "Password should contain at least one UPPERCASE letter": "Password should contain at least one UPPERCASE letter",
21
+ "Password should contain at least one number": "Password should contain at least one number",
22
+ "Password should have at least one special character": "Password should have at least one special character",
23
+ "Please provide a username between 4 and 255 characters": "Please provide a username between 4 and 255 characters",
24
+ "Please provide a valid email address": "Please provide a valid email address",
25
+ "Please provide a value": "Please provide a value",
26
+ "Please provide a round number without decimals": "Please provide a round number without decimals",
27
+ "Please provide a valid international phone number.": "Please provide a valid international phone number.",
28
+ "Please provide a number": "Please provide a number",
29
+ "Please provide a string": "Please provide a string",
30
+ "Please provide a valid url": "Please provide a valid url"
31
31
  }
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "La contraseña debe contener al menos una letra MAYÚSCULA",
21
21
  "Password should contain at least one number": "La contraseña debe contener al menos un número",
22
22
  "Password should have at least one special character": "La contraseña debe tener al menos un carácter especial",
23
- "Please provide a username between 1 and 255 characters": "Proporcione un usuario de entre 1 y 255 caracteres",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Por favor proporcione un correo electrónico válido",
25
25
  "Please provide a value": "Proporcione un valor",
26
26
  "Please provide a round number without decimals": "Por favor, proporcione un número redondo sin decimales",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Le mot de passe doit contenir au moins une lettre MAJUSCULE",
21
21
  "Password should contain at least one number": "Le mot de passe doit contenir au moins un chiffre",
22
22
  "Password should have at least one special character": "Le mot de passe doit avoir au moins un caractère spécial",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Veuillez saisir une adresse email valide",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Passordet må inneholdet minst en STOR bokstav",
21
21
  "Password should contain at least one number": "Passord må inneholde minst et siffer",
22
22
  "Password should have at least one special character": "Passordet skal ha minst ett spesialtegn",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Vennligst fyll ut en gyldig e-postadresse",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "A senha deve conter pelo menos uma letra MAIÚSCULA",
21
21
  "Password should contain at least one number": "A senha deve conter pelo menos um número",
22
22
  "Password should have at least one special character": "A senha deve ter pelo menos um caractere especial",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Por favor forneça um endereço de e-mail válido",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Пароль должен содержать хотя бы одну ЗАГЛАВНУЮ букву",
21
21
  "Password should contain at least one number": "Пароль должен содержать хотя бы одну цифру",
22
22
  "Password should have at least one special character": "В пароле должен быть хотя бы один специальный символ",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Введите правильный адрес электронной почты",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Lösenordet ska innehålla minst en versal bokstav",
21
21
  "Password should contain at least one number": "Lösenordet måste innehålla minst en siffra",
22
22
  "Password should have at least one special character": "Lösenordet ska ha minst ett specialtecken",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Ange en giltig epost adress",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "",
21
21
  "Password should contain at least one number": "",
22
22
  "Password should have at least one special character": "",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Пароль таркибида камида 1 та БОШ ҳарф бўлиши лозим",
21
21
  "Password should contain at least one number": "Пароль таркибида камида 1 та рақам бўлиши лозим",
22
22
  "Password should have at least one special character": "Пароль таркибида камида 1 та махсус белги бўлиши лозим",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Илтимос, амалдаги е-почта манзилини кўрсатинг",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Parol tarkibida kamida 1 ta BOSh harf boʼlishi lozim",
21
21
  "Password should contain at least one number": "Parol tarkibida kamida 1 ta raqam boʼlishi lozim",
22
22
  "Password should have at least one special character": "Parol tarkibida kamida 1 ta maxsus belgi boʼlishi lozim",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Iltimos, amaldagi ye-pochta manzilini koʼrsating",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "Mật khẩu phải chứa ít nhất một chữ cái viết hoa",
21
21
  "Password should contain at least one number": "Mật khẩu phải chứa ít nhất một số",
22
22
  "Password should have at least one special character": "Mật khẩu phải có ít nhất một ký tự đặc biệt",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "Vui lòng cung cấp một địa chỉ email hợp lệ",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "口令至少包括一个大写字母",
21
21
  "Password should contain at least one number": "口令至少包括应该数字",
22
22
  "Password should have at least one special character": "口令至少包括一个特殊字符",
23
- "Please provide a username between 1 and 255 characters": "请提供 1 到 255 个字符之间的用户名",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "有效的邮箱",
25
25
  "Please provide a value": "请提供值",
26
26
  "Please provide a round number without decimals": "请提供一个没有小数的整数",
@@ -20,7 +20,7 @@
20
20
  "Password should contain at least one UPPERCASE letter": "口令至少包括一个大写字母",
21
21
  "Password should contain at least one number": "口令至少包括应该数字",
22
22
  "Password should have at least one special character": "口令至少包括一个特殊字符",
23
- "Please provide a username between 1 and 255 characters": "",
23
+ "Please provide a username between 4 and 255 characters": "",
24
24
  "Please provide a valid email address": "有效的邮箱",
25
25
  "Please provide a value": "",
26
26
  "Please provide a round number without decimals": "",
@@ -2,16 +2,24 @@ import { dhis2Username, invalidUsernameMessage } from '../dhis2Username.js';
2
2
  import { testValidatorValues, allowsEmptyValues } from '../test-helpers/index.js';
3
3
  describe('validator: dhis2Username', () => {
4
4
  allowsEmptyValues(dhis2Username);
5
- describe('allows all sorts of strings between 1 and 255 characters long', () => {
6
- testValidatorValues(dhis2Username, undefined, ['electricchicken', '1', //1
7
- 'sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss', //255
8
- 'some_username^%&*(', 'あいうえお']);
5
+ describe('constrains length of username to between 4 and 255 characters long', () => {
6
+ testValidatorValues(dhis2Username, undefined, ['s'.repeat(4), 's'.repeat(255), 'valid_username']);
7
+ testValidatorValues(dhis2Username, invalidUsernameMessage, ['1', 's', 's'.repeat(256)]);
9
8
  });
10
- describe('rejects other data types', () => {
11
- testValidatorValues(dhis2Username, invalidUsernameMessage, [1, true, {}, [], () => {}]);
9
+ describe('does not allow usernames to start with _, . or @', () => {
10
+ testValidatorValues(dhis2Username, invalidUsernameMessage, ['_xxx', '.xxx', '@xxx']);
11
+ });
12
+ describe('does not allow usernames to end with _, . or @', () => {
13
+ testValidatorValues(dhis2Username, invalidUsernameMessage, ['xxx_', 'xxx.', 'xxx@']);
14
+ });
15
+ describe('does not allow usernames to contain __, .. or @@', () => {
16
+ testValidatorValues(dhis2Username, invalidUsernameMessage, ['__xx', '..xx', '@@xx']);
12
17
  });
13
- describe('values that are too long', () => {
14
- testValidatorValues(dhis2Username, invalidUsernameMessage, ['ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss' //256
15
- ]);
18
+ describe('constrains characters in usernames to [a-z0-9._@]', () => {
19
+ testValidatorValues(dhis2Username, undefined, ['v@lid_user.name', '123another_v@lid_usern@me']);
20
+ testValidatorValues(dhis2Username, invalidUsernameMessage, ['あいうえお', 'some_username^%&*(']);
21
+ });
22
+ describe('rejects non-string data types', () => {
23
+ testValidatorValues(dhis2Username, invalidUsernameMessage, [1, true, {}, [], () => {}]);
16
24
  });
17
25
  });
@@ -1,7 +1,8 @@
1
1
  import i18n from '../locales/index.js';
2
2
  import { isEmpty, isString } from './helpers/index.js';
3
- const invalidUsernameMessage = i18n.t('Please provide a username between 1 and 255 characters');
3
+ const USERNAME_PATTERN = /^(?=.{4,255}$)(?![_.@])(?!.*[_.@]{2})[a-z0-9._@]+(?<![_.@])$/;
4
+ const invalidUsernameMessage = i18n.t('Please provide a username between 4 and 255 characters');
4
5
 
5
- const dhis2Username = value => isEmpty(value) || isString(value) && value.length >= 1 && value.length <= 255 ? undefined : invalidUsernameMessage;
6
+ const dhis2Username = value => isEmpty(value) || isString(value) && USERNAME_PATTERN.test(value) ? undefined : invalidUsernameMessage;
6
7
 
7
8
  export { dhis2Username, invalidUsernameMessage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2/ui-forms",
3
- "version": "7.11.2",
3
+ "version": "7.12.1",
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.0.0-beta.1",
37
- "@dhis2-ui/button": "7.11.2",
38
- "@dhis2-ui/checkbox": "7.11.2",
39
- "@dhis2-ui/field": "7.11.2",
40
- "@dhis2-ui/file-input": "7.11.2",
41
- "@dhis2-ui/input": "7.11.2",
42
- "@dhis2-ui/radio": "7.11.2",
43
- "@dhis2-ui/select": "7.11.2",
44
- "@dhis2-ui/switch": "7.11.2",
45
- "@dhis2-ui/text-area": "7.11.2",
37
+ "@dhis2-ui/button": "7.12.1",
38
+ "@dhis2-ui/checkbox": "7.12.1",
39
+ "@dhis2-ui/field": "7.12.1",
40
+ "@dhis2-ui/file-input": "7.12.1",
41
+ "@dhis2-ui/input": "7.12.1",
42
+ "@dhis2-ui/radio": "7.12.1",
43
+ "@dhis2-ui/select": "7.12.1",
44
+ "@dhis2-ui/switch": "7.12.1",
45
+ "@dhis2-ui/text-area": "7.12.1",
46
46
  "classnames": "^2.3.1",
47
47
  "final-form": "^4.20.2",
48
48
  "prop-types": "^15.7.2",