-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checking Valid AadharCard Number and Some Country Code and Name Validation #1710
Open
pnirmale
wants to merge
4
commits into
validatorjs:master
Choose a base branch
from
pnirmale:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,4 +71,4 @@ | |
"node": ">= 0.10" | ||
}, | ||
"license": "MIT" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default function isAadharCardNumber(str) { | ||
const aadhar = str; | ||
const adharcardTwelveDigit = /^\d{12}$/; | ||
const adharSixteenDigit = /^\d{16}$/; | ||
if (aadhar !== '') { | ||
if (aadhar.match(adharcardTwelveDigit)) { | ||
return true; | ||
} else if (aadhar.match(adharSixteenDigit)) { | ||
return true; | ||
} return false; | ||
} | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,255 @@ | ||
const isCountry = { | ||
AF: 'Afghanistan', | ||
AX: 'Aland Islands', | ||
AL: 'Albania', | ||
DZ: 'Algeria', | ||
AS: 'American Samoa', | ||
AD: 'Andorra', | ||
AO: 'Angola', | ||
AI: 'Anguilla', | ||
AQ: 'Antarctica', | ||
AG: 'Antigua And Barbuda', | ||
AR: 'Argentina', | ||
AM: 'Armenia', | ||
AW: 'Aruba', | ||
AU: 'Australia', | ||
AT: 'Austria', | ||
AZ: 'Azerbaijan', | ||
BS: 'Bahamas', | ||
BH: 'Bahrain', | ||
BD: 'Bangladesh', | ||
BB: 'Barbados', | ||
BY: 'Belarus', | ||
BE: 'Belgium', | ||
BZ: 'Belize', | ||
BJ: 'Benin', | ||
BM: 'Bermuda', | ||
BT: 'Bhutan', | ||
BO: 'Bolivia', | ||
BA: 'Bosnia And Herzegovina', | ||
BW: 'Botswana', | ||
BV: 'Bouvet Island', | ||
BR: 'Brazil', | ||
IO: 'British Indian Ocean Territory', | ||
BN: 'Brunei Darussalam', | ||
BG: 'Bulgaria', | ||
BF: 'Burkina Faso', | ||
BI: 'Burundi', | ||
KH: 'Cambodia', | ||
CM: 'Cameroon', | ||
CA: 'Canada', | ||
CV: 'Cape Verde', | ||
KY: 'Cayman Islands', | ||
CF: 'Central African Republic', | ||
TD: 'Chad', | ||
CL: 'Chile', | ||
CN: 'China', | ||
CX: 'Christmas Island', | ||
CC: 'Cocos (Keeling) Islands', | ||
CO: 'Colombia', | ||
KM: 'Comoros', | ||
CG: 'Congo', | ||
CD: 'Congo, Democratic Republic', | ||
CK: 'Cook Islands', | ||
CR: 'Costa Rica', | ||
CI: 'Cote D\'Ivoire', | ||
HR: 'Croatia', | ||
CU: 'Cuba', | ||
CY: 'Cyprus', | ||
CZ: 'Czech Republic', | ||
DK: 'Denmark', | ||
DJ: 'Djibouti', | ||
DM: 'Dominica', | ||
DO: 'Dominican Republic', | ||
EC: 'Ecuador', | ||
EG: 'Egypt', | ||
SV: 'El Salvador', | ||
GQ: 'Equatorial Guinea', | ||
ER: 'Eritrea', | ||
EE: 'Estonia', | ||
ET: 'Ethiopia', | ||
FK: 'Falkland Islands (Malvinas)', | ||
FO: 'Faroe Islands', | ||
FJ: 'Fiji', | ||
FI: 'Finland', | ||
FR: 'France', | ||
GF: 'French Guiana', | ||
PF: 'French Polynesia', | ||
TF: 'French Southern Territories', | ||
GA: 'Gabon', | ||
GM: 'Gambia', | ||
GE: 'Georgia', | ||
DE: 'Germany', | ||
GH: 'Ghana', | ||
GI: 'Gibraltar', | ||
GR: 'Greece', | ||
GL: 'Greenland', | ||
GD: 'Grenada', | ||
GP: 'Guadeloupe', | ||
GU: 'Guam', | ||
GT: 'Guatemala', | ||
GG: 'Guernsey', | ||
GN: 'Guinea', | ||
GW: 'Guinea-Bissau', | ||
GY: 'Guyana', | ||
HT: 'Haiti', | ||
HM: 'Heard Island & Mcdonald Islands', | ||
VA: 'Holy See (Vatican City State)', | ||
HN: 'Honduras', | ||
HK: 'Hong Kong', | ||
HU: 'Hungary', | ||
IS: 'Iceland', | ||
IN: 'India', | ||
ID: 'Indonesia', | ||
IR: 'Iran, Islamic Republic Of', | ||
IQ: 'Iraq', | ||
IE: 'Ireland', | ||
IM: 'Isle Of Man', | ||
IL: 'Israel', | ||
IT: 'Italy', | ||
JM: 'Jamaica', | ||
JP: 'Japan', | ||
JE: 'Jersey', | ||
JO: 'Jordan', | ||
KZ: 'Kazakhstan', | ||
KE: 'Kenya', | ||
KI: 'Kiribati', | ||
KR: 'Korea', | ||
KW: 'Kuwait', | ||
KG: 'Kyrgyzstan', | ||
LA: 'Lao People\'s Democratic Republic', | ||
LV: 'Latvia', | ||
LB: 'Lebanon', | ||
LS: 'Lesotho', | ||
LR: 'Liberia', | ||
LY: 'Libyan Arab Jamahiriya', | ||
LI: 'Liechtenstein', | ||
LT: 'Lithuania', | ||
LU: 'Luxembourg', | ||
MO: 'Macao', | ||
MK: 'Macedonia', | ||
MG: 'Madagascar', | ||
MW: 'Malawi', | ||
MY: 'Malaysia', | ||
MV: 'Maldives', | ||
ML: 'Mali', | ||
MT: 'Malta', | ||
MH: 'Marshall Islands', | ||
MQ: 'Martinique', | ||
MR: 'Mauritania', | ||
MU: 'Mauritius', | ||
YT: 'Mayotte', | ||
MX: 'Mexico', | ||
FM: 'Micronesia, Federated States Of', | ||
MD: 'Moldova', | ||
MC: 'Monaco', | ||
MN: 'Mongolia', | ||
ME: 'Montenegro', | ||
MS: 'Montserrat', | ||
MA: 'Morocco', | ||
MZ: 'Mozambique', | ||
MM: 'Myanmar', | ||
NA: 'Namibia', | ||
NR: 'Nauru', | ||
NP: 'Nepal', | ||
NL: 'Netherlands', | ||
AN: 'Netherlands Antilles', | ||
NC: 'New Caledonia', | ||
NZ: 'New Zealand', | ||
NI: 'Nicaragua', | ||
NE: 'Niger', | ||
NG: 'Nigeria', | ||
NU: 'Niue', | ||
NF: 'Norfolk Island', | ||
MP: 'Northern Mariana Islands', | ||
NO: 'Norway', | ||
OM: 'Oman', | ||
PK: 'Pakistan', | ||
PW: 'Palau', | ||
PS: 'Palestinian Territory, Occupied', | ||
PA: 'Panama', | ||
PG: 'Papua New Guinea', | ||
PY: 'Paraguay', | ||
PE: 'Peru', | ||
PH: 'Philippines', | ||
PN: 'Pitcairn', | ||
PL: 'Poland', | ||
PT: 'Portugal', | ||
PR: 'Puerto Rico', | ||
QA: 'Qatar', | ||
RE: 'Reunion', | ||
RO: 'Romania', | ||
RU: 'Russian Federation', | ||
RW: 'Rwanda', | ||
BL: 'Saint Barthelemy', | ||
SH: 'Saint Helena', | ||
KN: 'Saint Kitts And Nevis', | ||
LC: 'Saint Lucia', | ||
MF: 'Saint Martin', | ||
PM: 'Saint Pierre And Miquelon', | ||
VC: 'Saint Vincent And Grenadines', | ||
WS: 'Samoa', | ||
SM: 'San Marino', | ||
ST: 'Sao Tome And Principe', | ||
SA: 'Saudi Arabia', | ||
SN: 'Senegal', | ||
RS: 'Serbia', | ||
SC: 'Seychelles', | ||
SL: 'Sierra Leone', | ||
SG: 'Singapore', | ||
SK: 'Slovakia', | ||
SI: 'Slovenia', | ||
SB: 'Solomon Islands', | ||
SO: 'Somalia', | ||
ZA: 'South Africa', | ||
GS: 'South Georgia And Sandwich Isl.', | ||
ES: 'Spain', | ||
LK: 'Sri Lanka', | ||
SD: 'Sudan', | ||
SR: 'Suriname', | ||
SJ: 'Svalbard And Jan Mayen', | ||
SZ: 'Swaziland', | ||
SE: 'Sweden', | ||
CH: 'Switzerland', | ||
SY: 'Syrian Arab Republic', | ||
TW: 'Taiwan', | ||
TJ: 'Tajikistan', | ||
TZ: 'Tanzania', | ||
TH: 'Thailand', | ||
TL: 'Timor-Leste', | ||
TG: 'Togo', | ||
TK: 'Tokelau', | ||
TO: 'Tonga', | ||
TT: 'Trinidad And Tobago', | ||
TN: 'Tunisia', | ||
TR: 'Turkey', | ||
TM: 'Turkmenistan', | ||
TC: 'Turks And Caicos Islands', | ||
TV: 'Tuvalu', | ||
UG: 'Uganda', | ||
UA: 'Ukraine', | ||
AE: 'United Arab Emirates', | ||
GB: 'United Kingdom', | ||
US: 'United States', | ||
UM: 'United States Outlying Islands', | ||
UY: 'Uruguay', | ||
UZ: 'Uzbekistan', | ||
VU: 'Vanuatu', | ||
VE: 'Venezuela', | ||
VN: 'Viet Nam', | ||
VG: 'Virgin Islands, British', | ||
VI: 'Virgin Islands, U.S.', | ||
WF: 'Wallis And Futuna', | ||
EH: 'Western Sahara', | ||
YE: 'Yemen', | ||
ZM: 'Zambia', | ||
ZW: 'Zimbabwe', | ||
}; | ||
|
||
export default function isCountryByCode(countryCode) { | ||
countryCode.toUpperCase(); | ||
if (isCountry.hasOwnProperty(countryCode)) { | ||
return isCountry[countryCode]; | ||
} | ||
return 'Invalid Countrycode'; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you discard your changes to this file?
I suppose you made a copy/paste error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help. I'm not sure what it is exactly you'd like me to delete, could you please point i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point it out, obviously I have no clue what I'm doing or how I wound up here. Sorry about that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes Surely I do required changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your opinion about isCountryByCode i could change to isvalidCountryCode ?
My opinion about isValidCountryName= it will beneficial when we are not providing those search country option