From 56105dea48cf59ecf59abd8e7979fd9c82d17bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Jarmu=C5=82a?= Date: Tue, 20 Aug 2024 11:23:46 +0200 Subject: [PATCH 1/3] update lan validator to accept max 30 signs --- lib/main/general-validators.ts | 2 +- test/general-validators.spec.ts | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/main/general-validators.ts b/lib/main/general-validators.ts index 42fa6ea..ac8835e 100644 --- a/lib/main/general-validators.ts +++ b/lib/main/general-validators.ts @@ -220,7 +220,7 @@ export const isLanNumberValidator = (value: string, country?: string): boolean = US: /^[A-Za-z0-9]{9,30}$/, UY: /^[0-9]{7,14}$/, } - const defaultRule = /^[A-Za-z0-9]{1,22}$/ + const defaultRule = /^[A-Za-z0-9]{1,30}$/ return !!value.replace(/ /g, '').match(lanCountriesRules[country] ? lanCountriesRules[country] : defaultRule) } /** diff --git a/test/general-validators.spec.ts b/test/general-validators.spec.ts index 75a433e..603c9ac 100644 --- a/test/general-validators.spec.ts +++ b/test/general-validators.spec.ts @@ -285,8 +285,8 @@ describe('Validators', () => { { country: 'SG', min: 1, max: 14 }, { country: 'TW', min: 1, max: 22 }, { country: 'US', min: 9, max: 30 }, - { country: 'OTHER', min: 1, max: 22 }, - { country: undefined, min: 1, max: 22 }, + { country: 'OTHER', min: 1, max: 30 }, + { country: undefined, min: 1, max: 30 }, ].forEach(({ country, min, max }) => describe(`isLanNumberValidator() validation behaviour for ${country} country code`, () => { it('should return true for valid lan number', () => { @@ -336,12 +336,6 @@ describe('Validators', () => { expect(isLanNumberValidator(`ZZZ${rawNumber}`, 'CN')).toBeFalsy() expect(isLanNumberValidator(`111${rawNumber}`, 'CN')).toBeFalsy() }) - - it('should not allow prefixes for other countries', async () => { - expect(isLanNumberValidator(`OSA${rawNumber}`, 'XX')).toBeFalsy() - expect(isLanNumberValidator(`NRA${rawNumber}`, 'XX')).toBeFalsy() - expect(isLanNumberValidator(`FTN${rawNumber}`, 'XX')).toBeFalsy() - }) }) it('should isRoutingCodeValidator() validate value correctly', () => { From 4e43cf26291d70431431fd6f272826523629704b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Jarmu=C5=82a?= Date: Tue, 20 Aug 2024 11:26:25 +0200 Subject: [PATCH 2/3] 1.1.25 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 15e4302..498ac7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@currency-one/validators", - "version": "1.1.24", + "version": "1.1.25", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@currency-one/validators", - "version": "1.1.24", + "version": "1.1.25", "license": "MIT", "devDependencies": { "@babel/cli": "^7.12.13", diff --git a/package.json b/package.json index 19ab20d..679e16a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@currency-one/validators", - "version": "1.1.24", + "version": "1.1.25", "description": "Typescript collection of validators and regexp patterns", "main": "./index.js", "types": "./index.d.ts", From 9aeef0acbe1618aaf7dc30527a210f983bf3f0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Jarmu=C5=82a?= Date: Tue, 20 Aug 2024 11:26:51 +0200 Subject: [PATCH 3/3] 1.1.26 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 498ac7d..d112492 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@currency-one/validators", - "version": "1.1.25", + "version": "1.1.26", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@currency-one/validators", - "version": "1.1.25", + "version": "1.1.26", "license": "MIT", "devDependencies": { "@babel/cli": "^7.12.13", diff --git a/package.json b/package.json index 679e16a..660430a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@currency-one/validators", - "version": "1.1.25", + "version": "1.1.26", "description": "Typescript collection of validators and regexp patterns", "main": "./index.js", "types": "./index.d.ts",