-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.js
1718 lines (1676 loc) ยท 37.8 KB
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//You can add and export any helper functions you want here. If you aren't using any, then you can just leave this file as is.
//Used professor's lecture code 5 and my lab6 helper functions i created previously for my reference
import {ObjectId} from 'mongodb';
const exportedMethods = {
description: 'This is my helper function for lab-10',
checkId(id) {
if (!id){
throw 'Error: You must provide an id to search for';
}
if (typeof id !== 'string') {
throw 'Error: id must be a string';
}
id = id.trim();
if (id.length === 0) {
throw 'Error: id cannot be an empty string or just spaces';
}
if (!ObjectId.isValid(id)) {
throw 'Error: invalid object ID';
}
return id;
},
checkString(strVal, varName) {
if (!strVal) throw `Error: You must supply a ${varName}!`;
if (typeof strVal !== 'string') throw `Error: ${varName} must be a string!`;
strVal = strVal.trim();
if (strVal.length === 0) throw `Error: ${varName} cannot be an empty string or string with just spaces`;
if (!isNaN(strVal)) throw `Error: ${strVal} is not a valid value for ${varName} as it only contains digits`;
return strVal;
},
isString(input){
if(typeof input === string){
return true;
}else{
return false;
}
},
checkCreateUserInputs(firstName, lastName, emailAddress, password, role){
let errorMsg = `All fields need to have valid values`;
if(!firstName){
throw errorMsg;
}
if(!lastName){
throw errorMsg;
}
if(!emailAddress){
throw errorMsg;
}
if(!password){
throw errorMsg;
}
if(!role){
throw errorMsg;
}
},
checkEmptyInputString(str, type){
if(!str){
throw `${type} can't be empty!`
}else if(typeof str !== 'string'){
throw `${type} should be a string`
}else if(str.trim() === ""){
throw `${type} can't be empty spaces, must be a valid string input`
}
return str.trim()
},
checkValidEmail(email){
//took reference from https://www.simplilearn.com/tutorials/javascript-tutorial/email-validation-in-javascript
//const emailRegEx = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
//took reference from https://www.w3resource.com/javascript/form/email-validation.php#:~:text=To%20get%20a%20valid%20email,%5D%2B)*%24%2F.
const emailRegEx = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
const isValid = emailRegEx.test(email);
if(!isValid){
throw `${email} is not of a valid email format! please make sure you have provided a valid email address format like -> [email protected]`
}
console.log(`Valid Email - ${email}`);
return isValid
},
checkValidPassword(password){
if(password.length < 8){
throw `Error: Password too short! Length of password must be a minimum of 8 Charecters long and can't be empty spaces..`;
}
let containsSpace = /\s/.test(password);
if (containsSpace) {
throw `Error: Your Password should not contain spaces!!`;
}
let containsUpper = /[A-Z]/.test(password);
if(!containsUpper){
throw `Error: Password must contain atleast one Upper Case Charecter!!`;
}
let containsNumber = /[0-9]/.test(password);
if(!containsNumber){
throw `Error: Password must contain atleast one Number!!`;
}
//took reference from this -> https://codingbeautydev.com/blog/javascript-check-if-string-contains-special-characters/#:~:text=So%2C%20some()%20returns%20true,at%20least%20one%20special%20character.
let containsSpecial = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/.test(password);
if(!containsSpecial){
throw `Error: Password must contain atleast one Special Charecter!!`;
}
console.log(`Valid password - ${password} exist`);
},
checkNameInput(name, type){
//console.log("Check name input function is called!!");
let nameRegex = /^[A-Za-z]{2,25}$/.test(name);
if(!nameRegex){
throw `Error: ${name} should be a valid ${type}!, should be 2 to 25 charecters long, non empty spaces containing only alphabets and no numbers..`
}
console.log(`Valid ${name} of type ${type} exist`);
},
checkPasswordsMatch(password, confirmPassword){
if(password!==confirmPassword){
throw `Error: Password and Confirm Password don't match!!`
}
console.log(`Passwords match!!`);
},
checkValiduserType(userType){
let validUserTypes = ["primary user", "scout user"];
let isValid = validUserTypes.includes(userType);
if(!isValid){
throw `The User Type - ${userType} you entered is invalid. Please make sure you select either "Primary User" or "Scout User" User Type only!!`
}
console.log(`${userType} is a valid user type`);
},
countryCodeExists(dial_code) {
for (let i = 0; i < this.countryCodes.length; i++) {
// If the current object's code key matches the provided code, return true
if (this.countryCodes[i].dial_code === dial_code) {
console.log(`Valid country code ${dial_code} exist`);
return true;
}
}
// If no match is found, return false
throw `Error: ${dial_code} is an Invalid Country Code!`;
},
validPhoneNumber(phoneNumber){
let phoneNumberRegex = /[0-9]{10}/.test(phoneNumber);
if(!phoneNumberRegex){
throw `Error: Phone Number ${phoneNumber} Entered by you is not a valid! Phone number should be a 10 digit number`;
}
},
validCountrySelected(country, codeCountry, countryCode){
console.log(country);
for (let i = 0; i < this.countryCodes.length; i++) {
// If the current object's code key matches the provided code, return true
if (this.countryCodes[i].name === country) {
console.log(`Valid Country name ${country} selected`);
return true;
}
if(country!==codeCountry){
throw `The country ${country} you selected doesn't match the country associated with the country code ${countryCode} ${codeCountry} you selected!`
}
}
// If no match is found, return false
throw `Error: ${country} is an Invalid Country Name!`;
},
findCountry(countryCode){
let country = "";
for(let i=0; i<this.countryCodes.length; i++){
if(countryCode === this.countryCodes[i].dial_code){
country = this.countryCodes[i].name;
return country;
}
}
return country;
},
countryCalculator(countryCode){
let countryList = [];
for(let i=0; i<countryCode.length; i++){
countryList.push(countryCode[i].name)
}
//console.log("CountryList, ", countryList);
return countryList;
},
checkValidAge(dob){
const dobInput = new Date(dob);
const currentDate = new Date();
//subtracting 18 years from current year so that i can directly see if the age difference is 18 or more
currentDate.setFullYear(currentDate.getFullYear() - 18);
const age = new Date().getFullYear() - dobInput.getFullYear();
if (dobInput > currentDate) {
throw `Your current age is ${age}! You must be at least 18 years old to register in our application.`;
}
console.log(`Your age ${age} is valid`);
},
checkValidDate(date){
// referred this for dateRegex https://www.regextester.com/96683 to match yyyy-mm-dd format
dateRegex = /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/
if(!dateRegex.text(date)){
throw `The date ${date} you entered is not of valid date format yyyy-mm-dd!`
}
},
//USED THIS REPO FOR COUNTRY CODE https://gist.githubusercontent.com/DmytroLisitsyn/1c31186e5b66f1d6c52da6b5c70b12ad/raw/2bc71083a77106afec2ec37cf49d05ee54be1a22/country_dial_info.json
defaultCountry: {
name: "United States",
flag: "๐บ๐ธ",
code: "US",
dial_code: "+1"
},
countryCodes: [
{
name: "Afghanistan",
flag: "๐ฆ๐ซ",
code: "AF",
dial_code: "+93"
},
{
name: "ร
land Islands",
flag: "๐ฆ๐ฝ",
code: "AX",
dial_code: "+358"
},
{
name: "Albania",
flag: "๐ฆ๐ฑ",
code: "AL",
dial_code: "+355"
},
{
name: "Algeria",
flag: "๐ฉ๐ฟ",
code: "DZ",
dial_code: "+213"
},
{
name: "American Samoa",
flag: "๐ฆ๐ธ",
code: "AS",
dial_code: "+1684"
},
{
name: "Andorra",
flag: "๐ฆ๐ฉ",
code: "AD",
dial_code: "+376"
},
{
name: "Angola",
flag: "๐ฆ๐ด",
code: "AO",
dial_code: "+244"
},
{
name: "Anguilla",
flag: "๐ฆ๐ฎ",
code: "AI",
dial_code: "+1264"
},
{
name: "Antarctica",
flag: "๐ฆ๐ถ",
code: "AQ",
dial_code: "+672"
},
{
name: "Antigua and Barbuda",
flag: "๐ฆ๐ฌ",
code: "AG",
dial_code: "+1268"
},
{
name: "Argentina",
flag: "๐ฆ๐ท",
code: "AR",
dial_code: "+54"
},
{
name: "Armenia",
flag: "๐ฆ๐ฒ",
code: "AM",
dial_code: "+374"
},
{
name: "Aruba",
flag: "๐ฆ๐ผ",
code: "AW",
dial_code: "+297"
},
{
name: "Australia",
flag: "๐ฆ๐บ",
code: "AU",
dial_code: "+61"
},
{
name: "Austria",
flag: "๐ฆ๐น",
code: "AT",
dial_code: "+43"
},
{
name: "Azerbaijan",
flag: "๐ฆ๐ฟ",
code: "AZ",
dial_code: "+994"
},
{
name: "Bahamas",
flag: "๐ง๐ธ",
code: "BS",
dial_code: "+1242"
},
{
name: "Bahrain",
flag: "๐ง๐ญ",
code: "BH",
dial_code: "+973"
},
{
name: "Bangladesh",
flag: "๐ง๐ฉ",
code: "BD",
dial_code: "+880"
},
{
name: "Barbados",
flag: "๐ง๐ง",
code: "BB",
dial_code: "+1246"
},
{
name: "Belarus",
flag: "๐ง๐พ",
code: "BY",
dial_code: "+375"
},
{
name: "Belgium",
flag: "๐ง๐ช",
code: "BE",
dial_code: "+32"
},
{
name: "Belize",
flag: "๐ง๐ฟ",
code: "BZ",
dial_code: "+501"
},
{
name: "Benin",
flag: "๐ง๐ฏ",
code: "BJ",
dial_code: "+229"
},
{
name: "Bermuda",
flag: "๐ง๐ฒ",
code: "BM",
dial_code: "+1441"
},
{
name: "Bhutan",
flag: "๐ง๐น",
code: "BT",
dial_code: "+975"
},
{
name: "Bolivia, Plurinational State of bolivia",
flag: "๐ง๐ด",
code: "BO",
dial_code: "+591"
},
{
name: "Bosnia and Herzegovina",
flag: "๐ง๐ฆ",
code: "BA",
dial_code: "+387"
},
{
name: "Botswana",
flag: "๐ง๐ผ",
code: "BW",
dial_code: "+267"
},
{
name: "Bouvet Island",
flag: "๐ง๐ป",
code: "BV",
dial_code: "+47"
},
{
name: "Brazil",
flag: "๐ง๐ท",
code: "BR",
dial_code: "+55"
},
{
name: "British Indian Ocean Territory",
flag: "๐ฎ๐ด",
code: "IO",
dial_code: "+246"
},
{
name: "Brunei Darussalam",
flag: "๐ง๐ณ",
code: "BN",
dial_code: "+673"
},
{
name: "Bulgaria",
flag: "๐ง๐ฌ",
code: "BG",
dial_code: "+359"
},
{
name: "Burkina Faso",
flag: "๐ง๐ซ",
code: "BF",
dial_code: "+226"
},
{
name: "Burundi",
flag: "๐ง๐ฎ",
code: "BI",
dial_code: "+257"
},
{
name: "Cambodia",
flag: "๐ฐ๐ญ",
code: "KH",
dial_code: "+855"
},
{
name: "Cameroon",
flag: "๐จ๐ฒ",
code: "CM",
dial_code: "+237"
},
{
name: "Canada",
flag: "๐จ๐ฆ",
code: "CA",
dial_code: "+1"
},
{
name: "Cape Verde",
flag: "๐จ๐ป",
code: "CV",
dial_code: "+238"
},
{
name: "Cayman Islands",
flag: "๐ฐ๐พ",
code: "KY",
dial_code: "+345"
},
{
name: "Central African Republic",
flag: "๐จ๐ซ",
code: "CF",
dial_code: "+236"
},
{
name: "Chad",
flag: "๐น๐ฉ",
code: "TD",
dial_code: "+235"
},
{
name: "Chile",
flag: "๐จ๐ฑ",
code: "CL",
dial_code: "+56"
},
{
name: "China",
flag: "๐จ๐ณ",
code: "CN",
dial_code: "+86"
},
{
name: "Christmas Island",
flag: "๐จ๐ฝ",
code: "CX",
dial_code: "+61"
},
{
name: "Cocos (Keeling) Islands",
flag: "๐จ๐จ",
code: "CC",
dial_code: "+61"
},
{
name: "Colombia",
flag: "๐จ๐ด",
code: "CO",
dial_code: "+57"
},
{
name: "Comoros",
flag: "๐ฐ๐ฒ",
code: "KM",
dial_code: "+269"
},
{
name: "Congo",
flag: "๐จ๐ฌ",
code: "CG",
dial_code: "+242"
},
{
name: "Congo, The Democratic Republic of the Congo",
flag: "๐จ๐ฉ",
code: "CD",
dial_code: "+243"
},
{
name: "Cook Islands",
flag: "๐จ๐ฐ",
code: "CK",
dial_code: "+682"
},
{
name: "Costa Rica",
flag: "๐จ๐ท",
code: "CR",
dial_code: "+506"
},
{
name: "Cote d'Ivoire",
flag: "๐จ๐ฎ",
code: "CI",
dial_code: "+225"
},
{
name: "Croatia",
flag: "๐ญ๐ท",
code: "HR",
dial_code: "+385"
},
{
name: "Cuba",
flag: "๐จ๐บ",
code: "CU",
dial_code: "+53"
},
{
name: "Cyprus",
flag: "๐จ๐พ",
code: "CY",
dial_code: "+357"
},
{
name: "Czech Republic",
flag: "๐จ๐ฟ",
code: "CZ",
dial_code: "+420"
},
{
name: "Denmark",
flag: "๐ฉ๐ฐ",
code: "DK",
dial_code: "+45"
},
{
name: "Djibouti",
flag: "๐ฉ๐ฏ",
code: "DJ",
dial_code: "+253"
},
{
name: "Dominica",
flag: "๐ฉ๐ฒ",
code: "DM",
dial_code: "+1767"
},
{
name: "Dominican Republic",
flag: "๐ฉ๐ด",
code: "DO",
dial_code: "+1849"
},
{
name: "Ecuador",
flag: "๐ช๐จ",
code: "EC",
dial_code: "+593"
},
{
name: "Egypt",
flag: "๐ช๐ฌ",
code: "EG",
dial_code: "+20"
},
{
name: "El Salvador",
flag: "๐ธ๐ป",
code: "SV",
dial_code: "+503"
},
{
name: "Equatorial Guinea",
flag: "๐ฌ๐ถ",
code: "GQ",
dial_code: "+240"
},
{
name: "Eritrea",
flag: "๐ช๐ท",
code: "ER",
dial_code: "+291"
},
{
name: "Estonia",
flag: "๐ช๐ช",
code: "EE",
dial_code: "+372"
},
{
name: "Ethiopia",
flag: "๐ช๐น",
code: "ET",
dial_code: "+251"
},
{
name: "Falkland Islands (Malvinas)",
flag: "๐ซ๐ฐ",
code: "FK",
dial_code: "+500"
},
{
name: "Faroe Islands",
flag: "๐ซ๐ด",
code: "FO",
dial_code: "+298"
},
{
name: "Fiji",
flag: "๐ซ๐ฏ",
code: "FJ",
dial_code: "+679"
},
{
name: "Finland",
flag: "๐ซ๐ฎ",
code: "FI",
dial_code: "+358"
},
{
name: "France",
flag: "๐ซ๐ท",
code: "FR",
dial_code: "+33"
},
{
name: "French Guiana",
flag: "๐ฌ๐ซ",
code: "GF",
dial_code: "+594"
},
{
name: "French Polynesia",
flag: "๐ต๐ซ",
code: "PF",
dial_code: "+689"
},
{
name: "French Southern Territories",
flag: "๐น๐ซ",
code: "TF",
dial_code: "+262"
},
{
name: "Gabon",
flag: "๐ฌ๐ฆ",
code: "GA",
dial_code: "+241"
},
{
name: "Gambia",
flag: "๐ฌ๐ฒ",
code: "GM",
dial_code: "+220"
},
{
name: "Georgia",
flag: "๐ฌ๐ช",
code: "GE",
dial_code: "+995"
},
{
name: "Germany",
flag: "๐ฉ๐ช",
code: "DE",
dial_code: "+49"
},
{
name: "Ghana",
flag: "๐ฌ๐ญ",
code: "GH",
dial_code: "+233"
},
{
name: "Gibraltar",
flag: "๐ฌ๐ฎ",
code: "GI",
dial_code: "+350"
},
{
name: "Greece",
flag: "๐ฌ๐ท",
code: "GR",
dial_code: "+30"
},
{
name: "Greenland",
flag: "๐ฌ๐ฑ",
code: "GL",
dial_code: "+299"
},
{
name: "Grenada",
flag: "๐ฌ๐ฉ",
code: "GD",
dial_code: "+1473"
},
{
name: "Guadeloupe",
flag: "๐ฌ๐ต",
code: "GP",
dial_code: "+590"
},
{
name: "Guam",
flag: "๐ฌ๐บ",
code: "GU",
dial_code: "+1671"
},
{
name: "Guatemala",
flag: "๐ฌ๐น",
code: "GT",
dial_code: "+502"
},
{
name: "Guernsey",
flag: "๐ฌ๐ฌ",
code: "GG",
dial_code: "+44"
},
{
name: "Guinea",
flag: "๐ฌ๐ณ",
code: "GN",
dial_code: "+224"
},
{
name: "Guinea-Bissau",
flag: "๐ฌ๐ผ",
code: "GW",
dial_code: "+245"
},
{
name: "Guyana",
flag: "๐ฌ๐พ",
code: "GY",
dial_code: "+592"
},
{
name: "Haiti",
flag: "๐ญ๐น",
code: "HT",
dial_code: "+509"
},
{
name: "Heard Island and Mcdonald Islands",
flag: "๐ญ๐ฒ",
code: "HM",
dial_code: "+672"
},
{
name: "Holy See (Vatican City State)",
flag: "๐ป๐ฆ",
code: "VA",
dial_code: "+379"
},
{
name: "Honduras",
flag: "๐ญ๐ณ",
code: "HN",
dial_code: "+504"
},
{
name: "Hong Kong",
flag: "๐ญ๐ฐ",
code: "HK",
dial_code: "+852"
},
{
name: "Hungary",
flag: "๐ญ๐บ",
code: "HU",
dial_code: "+36"
},
{
name: "Iceland",
flag: "๐ฎ๐ธ",
code: "IS",
dial_code: "+354"
},
{
name: "India",
flag: "๐ฎ๐ณ",
code: "IN",
dial_code: "+91"
},
{
name: "Indonesia",
flag: "๐ฎ๐ฉ",
code: "ID",
dial_code: "+62"
},
{
name: "Iran, Islamic Republic of Persian Gulf",
flag: "๐ฎ๐ท",
code: "IR",
dial_code: "+98"
},
{
name: "Iraq",
flag: "๐ฎ๐ถ",
code: "IQ",
dial_code: "+964"
},
{
name: "Ireland",
flag: "๐ฎ๐ช",
code: "IE",
dial_code: "+353"
},
{
name: "Isle of Man",
flag: "๐ฎ๐ฒ",
code: "IM",
dial_code: "+44"
},
{
name: "Israel",
flag: "๐ฎ๐ฑ",
code: "IL",
dial_code: "+972"
},
{
name: "Italy",
flag: "๐ฎ๐น",
code: "IT",
dial_code: "+39"
},
{
name: "Jamaica",
flag: "๐ฏ๐ฒ",
code: "JM",
dial_code: "+1876"
},
{
name: "Japan",
flag: "๐ฏ๐ต",
code: "JP",
dial_code: "+81"
},
{
name: "Jersey",
flag: "๐ฏ๐ช",
code: "JE",
dial_code: "+44"
},
{
name: "Jordan",
flag: "๐ฏ๐ด",
code: "JO",
dial_code: "+962"
},
{
name: "Kazakhstan",
flag: "๐ฐ๐ฟ",
code: "KZ",
dial_code: "+7"
},
{
name: "Kenya",
flag: "๐ฐ๐ช",
code: "KE",
dial_code: "+254"
},
{
name: "Kiribati",
flag: "๐ฐ๐ฎ",
code: "KI",
dial_code: "+686"
},
{
name: "Korea, Democratic People's Republic of Korea",
flag: "๐ฐ๐ต",
code: "KP",
dial_code: "+850"
},
{
name: "Korea, Republic of South Korea",
flag: "๐ฐ๐ท",
code: "KR",
dial_code: "+82"
},
{
name: "Kosovo",
flag: "๐ฝ๐ฐ",
code: "XK",
dial_code: "+383"
},
{
name: "Kuwait",
flag: "๐ฐ๐ผ",
code: "KW",
dial_code: "+965"
},
{
name: "Kyrgyzstan",
flag: "๐ฐ๐ฌ",
code: "KG",
dial_code: "+996"
},
{
name: "Laos",
flag: "๐ฑ๐ฆ",
code: "LA",
dial_code: "+856"
},
{
name: "Latvia",
flag: "๐ฑ๐ป",
code: "LV",
dial_code: "+371"
},
{
name: "Lebanon",
flag: "๐ฑ๐ง",
code: "LB",
dial_code: "+961"
},
{
name: "Lesotho",
flag: "๐ฑ๐ธ",
code: "LS",
dial_code: "+266"
},
{
name: "Liberia",
flag: "๐ฑ๐ท",
code: "LR",
dial_code: "+231"
},
{
name: "Libyan Arab Jamahiriya",
flag: "๐ฑ๐พ",
code: "LY",
dial_code: "+218"
},
{
name: "Liechtenstein",
flag: "๐ฑ๐ฎ",
code: "LI",
dial_code: "+423"
},
{
name: "Lithuania",
flag: "๐ฑ๐น",
code: "LT",
dial_code: "+370"
},
{