Skip to content

Commit 56acea3

Browse files
authored
chore: import validator functions individually (#3274)
1 parent 3e1f26c commit 56acea3

File tree

8 files changed

+86
-76
lines changed

8 files changed

+86
-76
lines changed

test/modules/commerce.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import validator from 'validator';
1+
import { isISBN } from 'validator';
22
import { describe, expect, it } from 'vitest';
33
import { faker } from '../../src';
44
import { seededTests } from '../support/seeded-runs';
@@ -204,7 +204,7 @@ describe('commerce', () => {
204204
isbn,
205205
'The expected match should be ISBN-13 with hyphens'
206206
).toMatch(/^978-[01]-[\d-]{9}-\d$/);
207-
expect(isbn).toSatisfy((isbn: string) => validator.isISBN(isbn, 13));
207+
expect(isbn).toSatisfy((isbn: string) => isISBN(isbn, 13));
208208
});
209209

210210
it('should return ISBN-10 with hyphen separators when passing variant 10 as argument', () => {
@@ -214,7 +214,7 @@ describe('commerce', () => {
214214
isbn,
215215
'The expected match should be ISBN-10 with hyphens'
216216
).toMatch(/^[01]-[\d-]{9}-[\dX]$/);
217-
expect(isbn).toSatisfy((isbn: string) => validator.isISBN(isbn, 10));
217+
expect(isbn).toSatisfy((isbn: string) => isISBN(isbn, 10));
218218
});
219219

220220
it('should return ISBN-13 with hyphen separators when passing variant 13 as argument', () => {
@@ -224,7 +224,7 @@ describe('commerce', () => {
224224
isbn,
225225
'The expected match should be ISBN-13 with hyphens'
226226
).toMatch(/^978-[01]-[\d-]{9}-\d$/);
227-
expect(isbn).toSatisfy((isbn: string) => validator.isISBN(isbn, 13));
227+
expect(isbn).toSatisfy((isbn: string) => isISBN(isbn, 13));
228228
});
229229

230230
it('should return ISBN-10 with space separators when passing variant 10 and space separators as argument', () => {
@@ -234,7 +234,7 @@ describe('commerce', () => {
234234
isbn,
235235
'The expected match should be ISBN-10 with space separators'
236236
).toMatch(/^[01] [\d ]{9} [\dX]$/);
237-
expect(isbn).toSatisfy((isbn: string) => validator.isISBN(isbn, 10));
237+
expect(isbn).toSatisfy((isbn: string) => isISBN(isbn, 10));
238238
});
239239

240240
it('should return ISBN-13 with space separators when passing space separators as argument', () => {
@@ -244,7 +244,7 @@ describe('commerce', () => {
244244
isbn,
245245
'The expected match should be ISBN-13 with space separators'
246246
).toMatch(/^978 [01] [\d ]{9} \d$/);
247-
expect(isbn).toSatisfy((isbn: string) => validator.isISBN(isbn, 13));
247+
expect(isbn).toSatisfy((isbn: string) => isISBN(isbn, 13));
248248
});
249249
});
250250
}

test/modules/finance-iban.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import validator from 'validator';
1+
import { isIBAN } from 'validator';
22
import { describe, expect, it } from 'vitest';
33
import { faker } from '../../src';
44
import { prettyPrintIban } from '../../src/modules/finance';
@@ -17,7 +17,7 @@ describe('finance_iban', () => {
1717
});
1818

1919
expect(actual).toMatch(new RegExp(`^${country}`));
20-
expect(actual).toSatisfy(validator.isIBAN);
20+
expect(actual).toSatisfy(isIBAN);
2121
});
2222
});
2323

@@ -41,7 +41,7 @@ describe('finance_iban', () => {
4141
countryCode: 'GE',
4242
});
4343

44-
expect(iban).toSatisfy(validator.isIBAN);
44+
expect(iban).toSatisfy(isIBAN);
4545

4646
const ibanFormatted = prettyPrintIban(iban);
4747
const bban = iban.substring(4) + iban.substring(0, 4);
@@ -104,7 +104,7 @@ describe('finance_iban', () => {
104104
countryCode: 'PK',
105105
});
106106

107-
expect(iban).toSatisfy(validator.isIBAN);
107+
expect(iban).toSatisfy(isIBAN);
108108

109109
const ibanFormated = prettyPrintIban(iban);
110110
const bban = iban.substring(4) + iban.substring(0, 4);
@@ -173,7 +173,7 @@ describe('finance_iban', () => {
173173
countryCode: 'TR',
174174
});
175175

176-
expect(iban).toSatisfy(validator.isIBAN);
176+
expect(iban).toSatisfy(isIBAN);
177177

178178
const ibanFormated = prettyPrintIban(iban);
179179
const bban = iban.substring(4) + iban.substring(0, 4);
@@ -246,7 +246,7 @@ describe('finance_iban', () => {
246246
countryCode: 'AZ',
247247
});
248248

249-
expect(iban).toSatisfy(validator.isIBAN);
249+
expect(iban).toSatisfy(isIBAN);
250250

251251
const ibanFormated = prettyPrintIban(iban);
252252
const bban = iban.substring(4) + iban.substring(0, 4);
@@ -308,7 +308,7 @@ describe('finance_iban', () => {
308308
countryCode: 'CR',
309309
});
310310

311-
expect(iban).toSatisfy(validator.isIBAN);
311+
expect(iban).toSatisfy(isIBAN);
312312

313313
const ibanFormated = prettyPrintIban(iban);
314314
const bban = iban.substring(4) + iban.substring(0, 4);
@@ -360,7 +360,7 @@ describe('finance_iban', () => {
360360
});
361361
const ibanFormated = prettyPrintIban(iban);
362362

363-
expect(iban).toSatisfy(validator.isIBAN);
363+
expect(iban).toSatisfy(isIBAN);
364364

365365
expect(
366366
28,

test/modules/git.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import validator from 'validator';
1+
import { isEmail, isHexadecimal, isSlug } from 'validator';
22
import { describe, expect, it } from 'vitest';
33
import { faker } from '../../src';
44
import { seededTests } from '../support/seeded-runs';
@@ -13,7 +13,7 @@ function isValidCommitAuthor(email: string): boolean {
1313
// that contain unquoted characters like . output by Git so we need
1414
// to quote the display name
1515
const quotedEmail = email.replace(/^(.*) </, '"$1" <');
16-
return validator.isEmail(quotedEmail, {
16+
return isEmail(quotedEmail, {
1717
require_display_name: true,
1818
});
1919
}
@@ -49,7 +49,7 @@ describe('git', () => {
4949

5050
expect(branch).toBeTruthy();
5151
expect(branch).toBeTypeOf('string');
52-
expect(branch).toSatisfy(validator.isSlug);
52+
expect(branch).toSatisfy(isSlug);
5353
});
5454
});
5555

@@ -145,7 +145,7 @@ describe('git', () => {
145145

146146
expect(commitSha).toBeTruthy();
147147
expect(commitSha).toBeTypeOf('string');
148-
expect(commitSha).toSatisfy(validator.isHexadecimal);
148+
expect(commitSha).toSatisfy(isHexadecimal);
149149
expect(commitSha).toHaveLength(40);
150150
});
151151

@@ -159,7 +159,7 @@ describe('git', () => {
159159

160160
expect(commitSha).toBeTruthy();
161161
expect(commitSha).toBeTypeOf('string');
162-
expect(commitSha).toSatisfy(validator.isHexadecimal);
162+
expect(commitSha).toSatisfy(isHexadecimal);
163163
expect(commitSha).toHaveLength(length);
164164
}
165165
);

0 commit comments

Comments
 (0)