Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following set of extra asserts are provided by this package:
| [CaZipCode](#cazipcode) | |
| [CpfNumber](#cpfnumber) | [`cpf`][cpf-url] |
| [CreditCard](#creditcard) | [`creditcard`][creditcard-url] |
| [CurpNumber](#curpnumber) | [`curp`][curp-url] |
| [CurpNumber](#curpnumber) | [`@randyd45/curp-validation`][curp-url] |
| [Date](#date) | [`moment`][moment-url] |
| [DateDiffGreaterThan](#datediffgreaterthan) | [`moment`][moment-url] |
| [DateDiffGreaterThanOrEqualTo](#datediffgreaterthanorequalto) | [`moment`][moment-url] |
Expand Down Expand Up @@ -402,7 +402,7 @@ MIT
[callback-url]: https://www.npmjs.com/package/callback
[cpf-url]: https://www.npmjs.com/package/cpf
[creditcard-url]: https://www.npmjs.com/package/creditcard
[curp-url]: https://www.npmjs.com/package/curp
[curp-url]: https://www.npmjs.com/package/@randyd45/curp-validation
[google-libphonenumber-url]: https://www.npmjs.com/package/google-libphonenumber
[iban-url]: https://www.npmjs.com/package/iban
[isoc-url]: https://www.npmjs.com/package/isoc
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
},
"devDependencies": {
"@fastify/pre-commit": "^2.2.0",
"@randyd45/curp-validation": "1.0.4",
"@uphold/github-changelog-generator": "^4.0.2",
"abavalidator": "^2.0.2",
"bignumber.js": "^9.3.0",
"cpf": "^2.0.1",
"creditcard": "^0.1.3",
"curp": "^1.3.1",
"eslint": "~9.28.0",
"eslint-config-uphold": "^6.5.2",
"google-libphonenumber": "^3.2.41",
Expand All @@ -73,11 +73,11 @@
"validator.js": "^2.0.0"
},
"peerDependencies": {
"@randyd45/curp-validation": "1.0.4",
"abavalidator": "^2.0.0",
"bignumber.js": ">=7 || <=9.3.0",
"cpf": "^2.0.1",
"creditcard": ">=0.0.1 <1.0.0",
"curp": "^1.2.3",
"google-libphonenumber": ">=1 <4",
"iban": ">=0.0.6 <1.0.0",
"isoc": ">=0.0.1 <1.0.0",
Expand All @@ -90,6 +90,9 @@
"validator.js": "^2.0.0"
},
"peerDependenciesMeta": {
"@randyd45/curp-validation": {
"optional": true
},
"abavalidator": {
"optional": true
},
Expand All @@ -102,9 +105,6 @@
"creditcard": {
"optional": true
},
"curp": {
"optional": true
},
"google-libphonenumber": {
"optional": true
},
Expand Down Expand Up @@ -137,11 +137,11 @@
"node": ">=20"
},
"optionalPeerDependencies": {
"@randyd45/curp-validation": "1.0.4",
"abavalidator": ">=2 <3",
"bignumber.js": ">=7 <=9.3.0",
"cpf": "^2.0.1",
"creditcard": ">=0.0.1 <1.0.0",
"curp": "^1.2.3",
"google-libphonenumber": ">=1 <4",
"iban": ">=0.0.6 <1.0.0",
"isoc": ">=0.0.1 <1.0.0",
Expand Down
10 changes: 5 additions & 5 deletions src/asserts/curp-number-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

const { Validator, Violation } = require('validator.js');
const _ = require('lodash');
let curp;
let CURP;

/**
* Optional peer dependencies.
*/

try {
curp = require('curp');
({ CURP } = require('@randyd45/curp-validation'));
// eslint-disable-next-line no-empty
} catch {}

Expand All @@ -22,8 +22,8 @@ try {
*/

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

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

if (!curp.validar(value)) {
if (!new CURP(value).isFormatValid()) {
throw new Violation(this, value, { value: 'must_be_a_valid_curp_number' });
}

Expand Down
2 changes: 1 addition & 1 deletion src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface ValidatorJSAsserts {

/**
* Valid Mexican CURP number.
* @requires curp
* @requires @randyd45/curp-validation
*/
curpNumber(): AssertInstance;

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,11 @@
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.2.7.tgz#eb5014dfd0b03e7f3ba2eeeff506eed89b028058"
integrity sha512-YLT9Zo3oNPJoBjBc4q8G2mjU4tqIbf5CEOORbUUr48dCD9q3umJ3IPlVqOqDakPfd2HuwccBaqlGhN4Gmr5OWg==

"@randyd45/curp-validation@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@randyd45/curp-validation/-/curp-validation-1.0.4.tgz#61212285894f772821ef1685fd22514150896839"
integrity sha512-UcmKskORce983tbpoS9bUESBUIYRjBPZ9bWPpY5S2fkXX0ImkVKCzSvWaqIfS6DPphmNtHyF+ifT9srqzs0EvA==

"@stylistic/eslint-plugin@^4.4.0":
version "4.4.1"
resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-4.4.1.tgz#410ac332887fb3d61cad1df4e6b55ae35d87c632"
Expand Down Expand Up @@ -1012,11 +1017,6 @@ cross-spawn@^7.0.3, cross-spawn@^7.0.6:
shebang-command "^2.0.0"
which "^2.0.1"

curp@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/curp/-/curp-1.3.1.tgz#6b944d490f5fcd1b60cf59951235b2c075737f9b"
integrity sha512-DoUGrXK7qe6qnSgumTGa9yULrMJy/1Npsgt0LkGkjWXfL/xVyJPcAQgyEJpNaJQjOlCvdEZWJ2K9vNlTmYrHHw==

data-uri-to-buffer@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz#8a58bb67384b261a38ef18bea1810cb01badd28b"
Expand Down
Loading