-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
429 additions
and
110 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
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 |
---|---|---|
@@ -1,34 +1,32 @@ | ||
/* eslint import/no-extraneous-dependencies: 0 */ | ||
import fs from 'fs'; | ||
import { rollup } from 'rollup'; | ||
import babel from 'rollup-plugin-babel'; | ||
import babelPresetEnv from '@babel/preset-env'; | ||
import pkg from './package.json'; | ||
import fs from "fs"; | ||
import { rollup } from "rollup"; | ||
import babel from "rollup-plugin-babel"; | ||
import babelPresetEnv from "@babel/preset-env"; | ||
import pkg from "./package.json"; | ||
|
||
rollup({ | ||
entry: 'src/index.js', | ||
entry: "src/index.js", | ||
plugins: [ | ||
babel({ | ||
presets: [[babelPresetEnv, { modules: false }]], | ||
babelrc: false, | ||
}), | ||
], | ||
}).then(bundle => ( | ||
bundle.write({ | ||
dest: 'validator.js', | ||
format: 'umd', | ||
moduleName: pkg.name, | ||
banner: ( | ||
`/*!\n${ | ||
String(fs.readFileSync('./LICENSE')) | ||
.trim() | ||
.split('\n') | ||
.map(l => ` * ${l}`) | ||
.join('\n') | ||
}\n */` | ||
), | ||
}) | ||
)).catch((e) => { | ||
process.stderr.write(`${e.message}\n`); | ||
process.exit(1); | ||
}); | ||
}) | ||
.then((bundle) => | ||
bundle.write({ | ||
dest: "validator.js", | ||
format: "umd", | ||
moduleName: pkg.name, | ||
banner: `/*!\n${String(fs.readFileSync("./LICENSE")) | ||
.trim() | ||
.split("\n") | ||
.map((l) => ` * ${l}`) | ||
.join("\n")}\n */`, | ||
}) | ||
) | ||
.catch((e) => { | ||
process.stderr.write(`${e.message}\n`); | ||
process.exit(1); | ||
}); |
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
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 |
---|---|---|
@@ -1,6 +1,15 @@ | ||
import assertString from './util/assertString'; | ||
|
||
export default function isBoolean(str) { | ||
const defaultOptions = { loose: false }; | ||
const strictBooleans = ['true', 'false', '1', '0']; | ||
const looseBooleans = [...strictBooleans, 'yes', 'no']; | ||
|
||
export default function isBoolean(str, options = defaultOptions) { | ||
assertString(str); | ||
return (['true', 'false', '1', '0'].indexOf(str) >= 0); | ||
|
||
if (options.loose) { | ||
return looseBooleans.includes(str.toLowerCase()); | ||
} | ||
|
||
return strictBooleans.includes(str); | ||
} |
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
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
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,38 @@ | ||
import assertString from './util/assertString'; | ||
|
||
// from https://en.wikipedia.org/wiki/ISO_4217 | ||
const validISO4217CurrencyCodes = new Set([ | ||
'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', | ||
'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BOV', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN', 'BZD', | ||
'CAD', 'CDF', 'CHE', 'CHF', 'CHW', 'CLF', 'CLP', 'CNY', 'COP', 'COU', 'CRC', 'CUC', 'CUP', 'CVE', 'CZK', | ||
'DJF', 'DKK', 'DOP', 'DZD', | ||
'EGP', 'ERN', 'ETB', 'EUR', | ||
'FJD', 'FKP', | ||
'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', | ||
'HKD', 'HNL', 'HRK', 'HTG', 'HUF', | ||
'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', | ||
'JMD', 'JOD', 'JPY', | ||
'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', | ||
'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LYD', | ||
'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRU', 'MUR', 'MVR', 'MWK', 'MXN', 'MXV', 'MYR', 'MZN', | ||
'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', | ||
'OMR', | ||
'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', | ||
'QAR', | ||
'RON', 'RSD', 'RUB', 'RWF', | ||
'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'SSP', 'STN', 'SVC', 'SYP', 'SZL', | ||
'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', | ||
'UAH', 'UGX', 'USD', 'USN', 'UYI', 'UYU', 'UYW', 'UZS', | ||
'VES', 'VND', 'VUV', | ||
'WST', | ||
'XAF', 'XAG', 'XAU', 'XBA', 'XBB', 'XBC', 'XBD', 'XCD', 'XDR', 'XOF', 'XPD', 'XPF', 'XPT', 'XSU', 'XTS', 'XUA', 'XXX', | ||
'YER', | ||
'ZAR', 'ZMW', 'ZWL', | ||
]); | ||
|
||
export default function isISO4217(str) { | ||
assertString(str); | ||
return validISO4217CurrencyCodes.has(str.toUpperCase()); | ||
} | ||
|
||
export const CurrencyCodes = validISO4217CurrencyCodes; |
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
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
Oops, something went wrong.