Last active
September 14, 2021 02:50
-
-
Save evikza/5102a26a15efc0fd53ea711639e9ca13 to your computer and use it in GitHub Desktop.
Проверка ОГРН и ОГРНИП
This file contains hidden or 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
| function isPrimaryStateRegistrationNumber($number) { | |
| let n = $number.length == 13 ? 11 : $number.length == 15 ? 13 : 0, | |
| j = $number.slice(0, -1), | |
| v = j / n, | |
| g = v.toString().replace(/\..*/gm, '') * n, | |
| f = (j - g).toString(), | |
| k = f > 9 ? f.slice(-1) : f, | |
| t = k == $number.toString().slice(-1); | |
| return t; | |
| } | |
| console.log(isPrimaryStateRegistrationNumber('1027700132195')); | |
| // -> true | |
| console.log(isPrimaryStateRegistrationNumber('5220710132791')); | |
| // -> false | |
| console.log(isPrimaryStateRegistrationNumber('313132804400022')); | |
| // -> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment