@optimiser/common 1.0.366 → 1.0.367

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.
@@ -63,6 +63,7 @@ declare const SubscribeEmailForAllDomains: (db: Db, email: string, isSubscribe:
63
63
  CountryCode?: string, //phone country code
64
64
  PhoneCallingCode?: CountryCallingCode, //phone country calling code
65
65
  PhoneNumberParsed?: NationalNumber, //phone no local to the country, without country calling code and only digits
66
+ ValidatedBy? : string, //Possible Values are SELF | COUNTRY_CODE, this field tells Phone No is valid by self or found valid with Country code
66
67
  Error: Error
67
68
  }
68
69
  */
@@ -901,6 +901,7 @@ exports.SubscribeEmailForAllDomains = SubscribeEmailForAllDomains;
901
901
  CountryCode?: string, //phone country code
902
902
  PhoneCallingCode?: CountryCallingCode, //phone country calling code
903
903
  PhoneNumberParsed?: NationalNumber, //phone no local to the country, without country calling code and only digits
904
+ ValidatedBy? : string, //Possible Values are SELF | COUNTRY_CODE, this field tells Phone No is valid by self or found valid with Country code
904
905
  Error: Error
905
906
  }
906
907
  */
@@ -908,6 +909,8 @@ var IsValidPhoneNumber = function (phoneNumber, countryCode) {
908
909
  var result = {}; //{ IsValid: false, CountryCode: string, PhoneCallingCode: null, PhoneNumberParsed: null };
909
910
  result.IsValid = false;
910
911
  result.CountryCode = result.PhoneCallingCode = result.PhoneNumberParsed = "";
912
+ //defaulty setting ValidatedBy flag that phone is validated by only phone no, so setting SELF.
913
+ result.ValidatedBy = "SELF";
911
914
  try {
912
915
  var phoneNumberParsed = null;
913
916
  try {
@@ -925,10 +928,12 @@ var IsValidPhoneNumber = function (phoneNumber, countryCode) {
925
928
  result.PhoneNumberParsed = phoneNumberParsed.nationalNumber;
926
929
  }
927
930
  }
928
- if (result.IsValid == false) {
931
+ //if any value is coming in countryCode then only we need to check phone number with country code
932
+ if (result.IsValid == false && countryCode) {
929
933
  //try {
930
934
  var phoneNumberParsedWithAddressCountry = null;
931
935
  try {
936
+ //checking phone no with given country code
932
937
  phoneNumberParsedWithAddressCountry = (0, libphonenumber_js_1.parsePhoneNumber)(phoneNumber, countryCode);
933
938
  }
934
939
  catch (error) {
@@ -941,6 +946,7 @@ var IsValidPhoneNumber = function (phoneNumber, countryCode) {
941
946
  result.CountryCode = phoneNumberParsedWithAddressCountry.country;
942
947
  result.PhoneCallingCode = phoneNumberParsedWithAddressCountry.countryCallingCode;
943
948
  result.PhoneNumberParsed = phoneNumberParsedWithAddressCountry.nationalNumber;
949
+ result.ValidatedBy = "COUNTRY_CODE";
944
950
  }
945
951
  }
946
952
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.366",
3
+ "version": "1.0.367",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {