-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
- Loading branch information
Showing
9 changed files
with
575 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { fake } from './core/core'; | ||
import { randSwift, SwiftOptions } from './swift'; | ||
|
||
/** | ||
* Generate a random swift bic code. | ||
* | ||
* @category finance | ||
* | ||
* @example | ||
* | ||
* randBic() | ||
* | ||
* @example | ||
* | ||
* randBic({ bankCode: 'DEUT' }) // bank code of Deutsche Bank | ||
* | ||
* @example | ||
* | ||
* randBic({ countryCode: 'DE' }) // country code with ISO country code | ||
* | ||
* @example | ||
* | ||
* randBic({ locationCode: 'MM' }) // location code for Milan MM for Frankfurt FF and etc | ||
* | ||
* @example | ||
* | ||
* randBic({ branchCode: '250' }) // bank branch code | ||
* | ||
* @example | ||
* | ||
* randBic({ fillBranchCode: true }) // bank branch code filled with XXX | ||
* | ||
* @example | ||
* | ||
* randBic({ length: 10 }) | ||
* | ||
*/ | ||
export function randBic<Options extends SwiftOptions = never>( | ||
options?: Options | ||
) { | ||
const _options = { ...options, length: undefined }; | ||
|
||
const factory: () => string = () => { | ||
return randSwift(_options).toString(); | ||
}; | ||
|
||
return fake(factory, options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { FakeOptions, fake } from './core/core'; | ||
import { randCountryCode } from './country-code'; | ||
import { randAlphaNumeric } from './alpha-numeric'; | ||
import { randAlpha } from './alpha'; | ||
|
||
export interface SwiftOptions extends FakeOptions { | ||
bankCode?: string; // [A-Z]{4} | ||
countryCode?: string; // [A-Z]{2} | ||
locationCode?: string; // [A-Z0-9]{2} | ||
branchCode?: string; // [A-Z0-9]{3} optional | ||
fillBranchCode?: boolean; // fill branchCode using XXX symbols | ||
} | ||
|
||
/** | ||
* Generate a random swift bic code. | ||
* | ||
* @category finance | ||
* | ||
* @example | ||
* | ||
* randSwift() | ||
* | ||
* @example | ||
* | ||
* randSwift({ bankCode: 'DEUT' }) // bank code of Deutsche Bank | ||
* | ||
* @example | ||
* | ||
* randSwift({ countryCode: 'DE' }) // country code with ISO country code | ||
* | ||
* @example | ||
* | ||
* randSwift({ locationCode: 'MM' }) // location code for Milan MM or for Frankfurt FF and etc | ||
* | ||
* @example | ||
* | ||
* randSwift({ branchCode: '250' }) // bank branch code | ||
* | ||
* @example | ||
* | ||
* randSwift({ fillBranchCode: true }) // bank branch code filled with XXX | ||
* | ||
* @example | ||
* | ||
* randSwift({ length: 10 }) | ||
* | ||
*/ | ||
export function randSwift<Options extends SwiftOptions = never>( | ||
options?: Options | ||
) { | ||
if (options?.bankCode && options?.bankCode?.length !== 4) { | ||
throw new Error('bank code should be valid 4 letters. For example DEUT'); | ||
} | ||
|
||
if (options?.countryCode && options?.countryCode?.length !== 2) { | ||
throw new Error( | ||
'country code should be valid ISO 3166-1 alpha-2 two-letter country code, for example: DE' | ||
); | ||
} | ||
|
||
if (options?.locationCode && options?.locationCode?.length !== 2) { | ||
throw new Error( | ||
'location code should be valid 2 characters, like FF or MM' | ||
); | ||
} | ||
|
||
if (options?.branchCode && options?.branchCode?.length !== 3) { | ||
throw new Error( | ||
'branch code should be valid 3 alpha numberic characters, like XXX or 250' | ||
); | ||
} | ||
|
||
const factory: () => string = () => { | ||
const bankCode: string = | ||
options?.bankCode ?? | ||
'####'.replace(/#/g, () => { | ||
return randAlpha(); | ||
}); | ||
|
||
const countryCode: string = options?.countryCode ?? randCountryCode(); | ||
|
||
const locationCode: string = | ||
options?.locationCode ?? | ||
'##'.replace(/#/g, () => { | ||
return randAlpha(); | ||
}); | ||
|
||
const branchCode: string = | ||
options?.branchCode ?? | ||
'###'.replace(/#/g, () => { | ||
return randAlphaNumeric().toString(); | ||
}); | ||
|
||
return `${bankCode}${countryCode}${locationCode}${ | ||
options?.fillBranchCode ? 'XXX' : branchCode | ||
}`.toUpperCase(); | ||
}; | ||
|
||
return fake(factory, options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,158 @@ | ||
{ | ||
"data": [ | ||
"Alpine", | ||
"Land Cruiser", | ||
"Grand Cherokee", | ||
"296 GTB", | ||
"4Runner", | ||
"500", | ||
"718", | ||
"911", | ||
"A-Class", | ||
"A2", | ||
"A3", | ||
"A4", | ||
"Golf", | ||
"A6", | ||
"A7", | ||
"A8", | ||
"Accord", | ||
"Expedition", | ||
"Camry", | ||
"Jetta", | ||
"Taurus", | ||
"Alpine", | ||
"Arteon", | ||
"Atlas", | ||
"Avalon", | ||
"Aventador", | ||
"Aviator", | ||
"Blazer", | ||
"Bronco", | ||
"C-Class", | ||
"C-HR", | ||
"Camaro", | ||
"Prius", | ||
"CX-9", | ||
"Wrangler", | ||
"Camry", | ||
"Cayenne", | ||
"Chiron", | ||
"Civic", | ||
"Clarity", | ||
"Clubman", | ||
"Colorado", | ||
"Corolla", | ||
"Corsair", | ||
"Corvette", | ||
"Countryman", | ||
"CR-V", | ||
"CT-4", | ||
"CT-5", | ||
"CX-9", | ||
"Duster", | ||
"e-tron", | ||
"E-Class", | ||
"Edge", | ||
"Elantra", | ||
"Escalade", | ||
"EQS", | ||
"EV-6", | ||
"Expedition", | ||
"Explorer", | ||
"F-150", | ||
"Fiesta", | ||
"Forester", | ||
"Ghibli", | ||
"Giulia", | ||
"GR86", | ||
"Grand Cherokee", | ||
"Grecale", | ||
"Golf", | ||
"Highlander", | ||
"HR-V", | ||
"Huracan", | ||
"ID.4", | ||
"Impreza", | ||
"Insight", | ||
"Ioniq", | ||
"Jetta", | ||
"John Cooper Works", | ||
"Kona", | ||
"Land Cruiser", | ||
"Legacy", | ||
"Levante", | ||
"Logan", | ||
"Lyriq", | ||
"M3", | ||
"M4", | ||
"M5", | ||
"Macan", | ||
"Malibu", | ||
"Maverick", | ||
"Mirai", | ||
"Model 3", | ||
"Model S", | ||
"Model X", | ||
"Model Y", | ||
"Mustang", | ||
"Nautilus", | ||
"Navigator", | ||
"Niro", | ||
"Outback", | ||
"Odyssey", | ||
"Palisade", | ||
"Panamera", | ||
"Passat", | ||
"Passport", | ||
"Portofino", | ||
"Prius", | ||
"Q3", | ||
"Q4", | ||
"Q5", | ||
"Q6", | ||
"Q7", | ||
"Q8", | ||
"Quattroporte", | ||
"Ranger", | ||
"R8", | ||
"RAV4", | ||
"Rio", | ||
"Roma", | ||
"S-Class", | ||
"Sandero", | ||
"Santa fe", | ||
"Sequoia", | ||
"Sentra", | ||
"Silverado" | ||
"Sienna", | ||
"Silverado", | ||
"Sonata", | ||
"Sorento", | ||
"Spark", | ||
"Sportage", | ||
"Spring", | ||
"Stelvio", | ||
"Stinger", | ||
"Suburban", | ||
"Super Duty", | ||
"Supra", | ||
"Tacoma", | ||
"Tahoe", | ||
"Tacoma", | ||
"Taos", | ||
"Taurus", | ||
"Taycan", | ||
"Tiguan", | ||
"Tonale", | ||
"Touareg", | ||
"Trailblazer", | ||
"TT", | ||
"Tucson", | ||
"Tundra", | ||
"Urus", | ||
"Veloster", | ||
"Venza", | ||
"Veyron", | ||
"Wrangler", | ||
"X1", | ||
"X2", | ||
"X3", | ||
"X4", | ||
"X5", | ||
"X6", | ||
"X7", | ||
"XT4", | ||
"XT5", | ||
"Yaris", | ||
"Z4" | ||
] | ||
} |
Oops, something went wrong.