@osimatic/helpers-js 1.0.95 → 1.0.96

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/CHANGELOG CHANGED
@@ -48,4 +48,7 @@ FormHelper.displayFormErrorsFromXhr(form, btnSubmit, xhr) -> FormHelper.displayF
48
48
  ajout méthode HTTPRequest.init() (charge le polyfill de fetch)
49
49
 
50
50
  1.0.61
51
- DataTable.displayErrorFromXhr -> DataTable.displayError
51
+ DataTable.displayErrorFromXhr -> DataTable.displayError
52
+
53
+ 1.0.96
54
+ var intlTelInputUtilsPath = 'xxx'; -> TelephoneNumber.setIntlTelInputUtilsPath('xxx');
@@ -2,7 +2,7 @@
2
2
  class PersonName {
3
3
 
4
4
  static format(firstName, lastName) {
5
- var str = '';
5
+ let str = '';
6
6
  if (firstName != null && firstName != '') {
7
7
  str += ' '+firstName;
8
8
  }
@@ -17,12 +17,8 @@ class PersonName {
17
17
  return false;
18
18
  }
19
19
 
20
- var regEx = /^([a-zA-Z'àâäéèêëìîïòôöùûüçÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇ\s-]+)$/;
21
- if (regEx.exec(firstName) == null) {
22
- return false;
23
- }
24
-
25
- return true;
20
+ let regEx = /^([a-zA-Z'àâäéèêëìîïòôöùûüçÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇ\s-]+)$/;
21
+ return regEx.exec(firstName) != null;
26
22
  }
27
23
 
28
24
  static checkLastName(lastName) {
@@ -30,30 +26,30 @@ class PersonName {
30
26
  return false;
31
27
  }
32
28
 
33
- var regEx = /^([a-zA-Z'àâäéèêëìîïòôöùûüçÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇ\s-]+)$/;
34
- if (regEx.exec(lastName) == null) {
35
- return false;
36
- }
37
-
38
- return true;
29
+ let regEx = /^([a-zA-Z'àâäéèêëìîïòôöùûüçÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇ\s-]+)$/;
30
+ return regEx.exec(lastName) != null;
39
31
  }
40
32
  }
41
33
 
42
34
  class Email {
43
35
  static validateEmail(email) {
44
- var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
36
+ let re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
45
37
  return re.test(email);
46
38
  }
47
39
 
48
40
  static checkEmail(email) {
49
- var regExEmail = /^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$/;
50
- return (regExEmail.exec(email) != null);
41
+ let regExEmail = /^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$/;
42
+ return regExEmail.exec(email) != null;
51
43
  }
52
44
  }
53
45
 
54
46
  class TelephoneNumber {
55
47
  //this class works with libphonenumber-max.min.js
56
-
48
+
49
+ static setIntlTelInputUtilsPath(path) {
50
+ TelephoneNumber.intlTelInputUtilsPath = path;
51
+ }
52
+
57
53
  static getCountryIsoCode(phoneNumber, localCountryIsoCode) {
58
54
  localCountryIsoCode = (typeof localCountryIsoCode != 'undefined' ? localCountryIsoCode.toUpperCase() : serviceCountry);
59
55
  return libphonenumber.parsePhoneNumber(phoneNumber, localCountryIsoCode).country || '';
@@ -99,19 +95,12 @@ class TelephoneNumber {
99
95
  }
100
96
 
101
97
  static checkSyntaxe(phoneNumber) {
102
- var verifPhoneFr = /^(0)[1-9]{1}[ \.\-]?[0-9]{2}[ \.\-]?[0-9]{2}[ \.\-]?[0-9]{2}[ \.\-]?[0-9]{2}$/;
103
- var verifPhoneInt = /^((\+)|(00))[1-9]{1}[0-9]{0,3}([ \.\-\/]?[0-9]{1}){4,20}$/;
104
- // var verifPhoneInt = /^((\+)|(00))([ \.\-\/]?[0-9]{1}){6-20}$/;
105
- //var verifPhone = /^[0-9+() .-]{6,32}$/;
98
+ let verifPhoneFr = /^(0)[1-9]{1}[ \.\-]?[0-9]{2}[ \.\-]?[0-9]{2}[ \.\-]?[0-9]{2}[ \.\-]?[0-9]{2}$/;
99
+ let verifPhoneInt = /^((\+)|(00))[1-9]{1}[0-9]{0,3}([ \.\-\/]?[0-9]{1}){4,20}$/;
106
100
  if (verifPhoneFr.exec(phoneNumber) != null) {
107
101
  return true;
108
102
  }
109
- if (verifPhoneInt.exec(phoneNumber) != null) {
110
- return true;
111
- }
112
- //console.log(verifPhoneInt);
113
- // console.log('"'+phoneNumber+'" not valid');
114
- return false;
103
+ return verifPhoneInt.exec(phoneNumber) != null;
115
104
  }
116
105
 
117
106
  static getType(phoneNumber, localCountryIsoCode) {
@@ -150,7 +139,7 @@ class TelephoneNumber {
150
139
  return window.intlTelInput(input[0], {
151
140
  initialCountry: serviceCountry,
152
141
  placeholderNumberType: placeholderNumberType || 'FIXED_LINE_OR_MOBILE',
153
- utilsScript: intlTelInputUtilsPath
142
+ utilsScript: typeof TelephoneNumber.intlTelInputUtilsPath != 'undefined' ? TelephoneNumber.intlTelInputUtilsPath : null
154
143
  });
155
144
  }
156
145
 
@@ -159,7 +148,7 @@ class TelephoneNumber {
159
148
  }
160
149
 
161
150
  static formatNumberFromIntlTelInput(intlTelInput) {
162
- var number = intlTelInput.getNumber();
151
+ let number = intlTelInput.getNumber();
163
152
  if (number != '' && number.substr(0, 1) !== '+') {
164
153
  number = '+' + intlTelInput.getSelectedCountryData().dialCode + number;
165
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.95",
3
+ "version": "1.0.96",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"