@itfin/components 2.0.20 → 2.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itfin/components",
3
- "version": "2.0.20",
3
+ "version": "2.0.22",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -12,6 +12,7 @@ const DOUBLE_REGEXP = /^-?\d{0,11}(\.\d{0,8}){0,1}$/;
12
12
  const EMAIL_REGEXP = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/g;
13
13
  const EMAIL_LIST_REGEXP = /^(\w+((-\w+)|(\.\w+))*@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}\s*?,?\s*?)+$/g;
14
14
  const HEX_REGEXP = /[0-9A-Fa-f]{6}/;
15
+ const PASSWORD_REGEX = /^(?=.*\p{Lu})(?=.*\p{Ll})(?=.*\d)(?=.*[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]).{8,}$/u;
15
16
 
16
17
  const STANDART_DATE_FORMAT = 'yyyy-MM-dd';
17
18
 
@@ -181,3 +182,9 @@ export function dateSameOrBeforeValidation (dateCompare, message) {
181
182
  return d1 <= d2 || (message || $t('components.dateSameOrBefore', { date: formatDate(dateCompare) }));
182
183
  };
183
184
  }
185
+
186
+ export function passwordValidation(message) {
187
+ return (v, $t) => {
188
+ return !isEmpty(v) && PASSWORD_REGEX.test(v.trim() + '') || (message || $t('components.passwordValidation'));
189
+ };
190
+ }
@@ -7,6 +7,7 @@ import {
7
7
  dateAfterValidation,
8
8
  dateSameOrAfterValidation,
9
9
  dateSameOrBeforeValidation,
10
+ passwordValidation,
10
11
  } from './validators';
11
12
 
12
13
  describe('Validators', () => {
@@ -81,4 +82,17 @@ describe('Validators', () => {
81
82
  expect(mediumTextValidation()('0'.repeat(16777215), $t)).toEqual(true);
82
83
  expect(mediumTextValidation()('0'.repeat(16777216), $t)).toEqual('components.mediumTextLength');
83
84
  });
85
+
86
+
87
+ test('passwordValidation', () => {
88
+ expect(passwordValidation()('', $t)).toEqual('components.passwordValidation');
89
+ expect(passwordValidation()(' ', $t)).toEqual('components.passwordValidation');
90
+ expect(passwordValidation()(null, $t)).toEqual('components.passwordValidation');
91
+ expect(passwordValidation()(undefined, $t)).toEqual('components.passwordValidation');
92
+ expect(passwordValidation()(' тесттест ', $t)).toEqual('components.passwordValidation');
93
+ expect(passwordValidation()(' ТЕСТТЕСТ ', $t)).toEqual('components.passwordValidation');
94
+ expect(passwordValidation()(' ТестТест ', $t)).toEqual('components.passwordValidation');
95
+ expect(passwordValidation()(' ТестТест1 ', $t)).toEqual('components.passwordValidation');
96
+ expect(passwordValidation()(' ТестТест1@ ', $t)).toEqual(true);
97
+ });
84
98
  });
package/src/locales/en.js CHANGED
@@ -152,5 +152,6 @@ module.exports = {
152
152
  from: 'From',
153
153
  to: 'To',
154
154
  value: 'Value',
155
- }
155
+ },
156
+ passwordValidation: 'Password should contain at least 8 characters, including uppercase letters, lowercase letters, numbers, and special characters (e.g. @, $, !, %, *, ?, &)',
156
157
  };
package/src/locales/uk.js CHANGED
@@ -152,5 +152,6 @@ module.exports = {
152
152
  from: 'Від',
153
153
  to: 'До',
154
154
  value: 'Значення',
155
- }
155
+ },
156
+ passwordValidation: 'Пароль має містити принаймні 8 символів, включаючи великі літери, малі літери, цифри та спеціальні символи (@, $, !, %, *, ?, &)',
156
157
  };