Skip to content

Commit

Permalink
Merge pull request #56 from Currency-One/lan-validator-update
Browse files Browse the repository at this point in the history
Lan validator update
  • Loading branch information
HiddeRpl authored Aug 20, 2024
2 parents 61b1a1b + 9aeef0a commit dbf66fd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/main/general-validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
/**
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@currency-one/validators",
"version": "1.1.24",
"version": "1.1.26",
"description": "Typescript collection of validators and regexp patterns",
"main": "./index.js",
"types": "./index.d.ts",
Expand Down
10 changes: 2 additions & 8 deletions test/general-validators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit dbf66fd

Please sign in to comment.