Skip to content

Commit f4bae8b

Browse files
committed
Replace curp lib with curp-validation
1 parent f998a3a commit f4bae8b

5 files changed

Lines changed: 19 additions & 19 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The following set of extra asserts are provided by this package:
4242
| [CaZipCode](#cazipcode) | |
4343
| [CpfNumber](#cpfnumber) | [`cpf`][cpf-url] |
4444
| [CreditCard](#creditcard) | [`creditcard`][creditcard-url] |
45-
| [CurpNumber](#curpnumber) | [`curp`][curp-url] |
45+
| [CurpNumber](#curpnumber) | [`@randyd45/curp-validation`][curp-url] |
4646
| [Date](#date) | [`moment`][moment-url] |
4747
| [DateDiffGreaterThan](#datediffgreaterthan) | [`moment`][moment-url] |
4848
| [DateDiffGreaterThanOrEqualTo](#datediffgreaterthanorequalto) | [`moment`][moment-url] |
@@ -402,7 +402,7 @@ MIT
402402
[callback-url]: https://www.npmjs.com/package/callback
403403
[cpf-url]: https://www.npmjs.com/package/cpf
404404
[creditcard-url]: https://www.npmjs.com/package/creditcard
405-
[curp-url]: https://www.npmjs.com/package/curp
405+
[curp-url]: https://www.npmjs.com/package/@randyd45/curp-validation
406406
[google-libphonenumber-url]: https://www.npmjs.com/package/google-libphonenumber
407407
[iban-url]: https://www.npmjs.com/package/iban
408408
[isoc-url]: https://www.npmjs.com/package/isoc

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
},
5252
"devDependencies": {
5353
"@fastify/pre-commit": "^2.2.0",
54+
"@randyd45/curp-validation": "1.0.4",
5455
"@uphold/github-changelog-generator": "^4.0.2",
5556
"abavalidator": "^2.0.2",
5657
"bignumber.js": "^9.3.0",
5758
"cpf": "^2.0.1",
5859
"creditcard": "^0.1.3",
59-
"curp": "^1.3.1",
6060
"eslint": "~9.28.0",
6161
"eslint-config-uphold": "^6.5.2",
6262
"google-libphonenumber": "^3.2.41",
@@ -73,11 +73,11 @@
7373
"validator.js": "^2.0.0"
7474
},
7575
"peerDependencies": {
76+
"@randyd45/curp-validation": "1.0.4",
7677
"abavalidator": "^2.0.0",
7778
"bignumber.js": ">=7 || <=9.3.0",
7879
"cpf": "^2.0.1",
7980
"creditcard": ">=0.0.1 <1.0.0",
80-
"curp": "^1.2.3",
8181
"google-libphonenumber": ">=1 <4",
8282
"iban": ">=0.0.6 <1.0.0",
8383
"isoc": ">=0.0.1 <1.0.0",
@@ -90,6 +90,9 @@
9090
"validator.js": "^2.0.0"
9191
},
9292
"peerDependenciesMeta": {
93+
"@randyd45/curp-validation": {
94+
"optional": true
95+
},
9396
"abavalidator": {
9497
"optional": true
9598
},
@@ -102,9 +105,6 @@
102105
"creditcard": {
103106
"optional": true
104107
},
105-
"curp": {
106-
"optional": true
107-
},
108108
"google-libphonenumber": {
109109
"optional": true
110110
},
@@ -137,11 +137,11 @@
137137
"node": ">=20"
138138
},
139139
"optionalPeerDependencies": {
140+
"@randyd45/curp-validation": "1.0.4",
140141
"abavalidator": ">=2 <3",
141142
"bignumber.js": ">=7 <=9.3.0",
142143
"cpf": "^2.0.1",
143144
"creditcard": ">=0.0.1 <1.0.0",
144-
"curp": "^1.2.3",
145145
"google-libphonenumber": ">=1 <4",
146146
"iban": ">=0.0.6 <1.0.0",
147147
"isoc": ">=0.0.1 <1.0.0",

src/asserts/curp-number-assert.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
const { Validator, Violation } = require('validator.js');
88
const _ = require('lodash');
9-
let curp;
9+
let CURP;
1010

1111
/**
1212
* Optional peer dependencies.
1313
*/
1414

1515
try {
16-
curp = require('curp');
16+
({ CURP } = require('@randyd45/curp-validation'));
1717
// eslint-disable-next-line no-empty
1818
} catch {}
1919

@@ -22,8 +22,8 @@ try {
2222
*/
2323

2424
module.exports = function curpNumberAssert() {
25-
if (!curp) {
26-
throw new Error('curp is not installed');
25+
if (!CURP) {
26+
throw new Error('@randyd45/curp-validation is not installed');
2727
}
2828

2929
/**
@@ -41,7 +41,7 @@ module.exports = function curpNumberAssert() {
4141
throw new Violation(this, value, { value: Validator.errorCode.must_be_a_string });
4242
}
4343

44-
if (!curp.validar(value)) {
44+
if (!new CURP(value).isFormatValid()) {
4545
throw new Violation(this, value, { value: 'must_be_a_valid_curp_number' });
4646
}
4747

src/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface ValidatorJSAsserts {
7474

7575
/**
7676
* Valid Mexican CURP number.
77-
* @requires curp
77+
* @requires @randyd45/curp-validation
7878
*/
7979
curpNumber(): AssertInstance;
8080

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,11 @@
629629
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.2.7.tgz#eb5014dfd0b03e7f3ba2eeeff506eed89b028058"
630630
integrity sha512-YLT9Zo3oNPJoBjBc4q8G2mjU4tqIbf5CEOORbUUr48dCD9q3umJ3IPlVqOqDakPfd2HuwccBaqlGhN4Gmr5OWg==
631631

632+
"@randyd45/curp-validation@1.0.4":
633+
version "1.0.4"
634+
resolved "https://registry.yarnpkg.com/@randyd45/curp-validation/-/curp-validation-1.0.4.tgz#61212285894f772821ef1685fd22514150896839"
635+
integrity sha512-UcmKskORce983tbpoS9bUESBUIYRjBPZ9bWPpY5S2fkXX0ImkVKCzSvWaqIfS6DPphmNtHyF+ifT9srqzs0EvA==
636+
632637
"@stylistic/eslint-plugin@^4.4.0":
633638
version "4.4.1"
634639
resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-4.4.1.tgz#410ac332887fb3d61cad1df4e6b55ae35d87c632"
@@ -1012,11 +1017,6 @@ cross-spawn@^7.0.3, cross-spawn@^7.0.6:
10121017
shebang-command "^2.0.0"
10131018
which "^2.0.1"
10141019

1015-
curp@^1.3.1:
1016-
version "1.3.1"
1017-
resolved "https://registry.yarnpkg.com/curp/-/curp-1.3.1.tgz#6b944d490f5fcd1b60cf59951235b2c075737f9b"
1018-
integrity sha512-DoUGrXK7qe6qnSgumTGa9yULrMJy/1Npsgt0LkGkjWXfL/xVyJPcAQgyEJpNaJQjOlCvdEZWJ2K9vNlTmYrHHw==
1019-
10201020
data-uri-to-buffer@^6.0.2:
10211021
version "6.0.2"
10221022
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz#8a58bb67384b261a38ef18bea1810cb01badd28b"

0 commit comments

Comments
 (0)