validatorjs / validator.js

String validation
MIT License
23.12k stars 2.31k forks source link

Adding 'isAdhaar' as a Validator #2027

Closed Akshat-Mishra101 closed 2 years ago

Akshat-Mishra101 commented 2 years ago

Hey guys, I need permission to add a validator for a popular Indian identity card, called the "Adhaar Card"

What is an Adhaar Number?

According to UIDAI -- Aadhaar number is a 12-digit random number issued by the UIDAI (“Authority”) to the residents of India after satisfying the verification process laid down by the Authority. Any individual, irrespective of age and gender, who is a resident of India, may voluntarily enrol to obtain Aadhaar number.

The rules for an adhaar number are as follows

braaar commented 2 years ago

I would suggest implementing this as a locale in isIdentityCard(str [, locale])

Akshat-Mishra101 commented 2 years ago

Sure, just one doubt though. Since we already have a locale for the indian region identity (which is not the same as adhaar) how would we include this new identity? or what locale would we choose?

braaar commented 2 years ago

I think adding it as a separate "locale" (not stricly a real locale, but I suppose it's justified when multiple standards exist within the same locale) is the cleanest option. IN-2, IN-2016, IN-UIDAI, IN-aadhaar perhaps?

braaar commented 2 years ago

I just looked into it, and according to the PR where it was added, the existing identity card validator in the INlocale is for aadhaar.

braaar commented 2 years ago

Take a look at the test cases to see what it validates: https://github.com/validatorjs/validator.js/blob/86a07ba4f3f710f639e92a62cf81dd3321ef9ee8/test/validators.js#L5222-L5235

Akshat-Mishra101 commented 2 years ago

Thanks braaar, this seems it; I'll close this issue. There are a couple of more identifications I'd like to add to this, which I'll open in the next few issues :)