Initial commit
This commit is contained in:
19
node_modules/validator/es/lib/isBase32.js
generated
vendored
Normal file
19
node_modules/validator/es/lib/isBase32.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import assertString from './util/assertString';
|
||||
import merge from './util/merge';
|
||||
var base32 = /^[A-Z2-7]+=*$/;
|
||||
var crockfordBase32 = /^[A-HJKMNP-TV-Z0-9]+$/;
|
||||
var defaultBase32Options = {
|
||||
crockford: false
|
||||
};
|
||||
export default function isBase32(str, options) {
|
||||
assertString(str);
|
||||
options = merge(options, defaultBase32Options);
|
||||
if (options.crockford) {
|
||||
return crockfordBase32.test(str);
|
||||
}
|
||||
var len = str.length;
|
||||
if (len % 8 === 0 && base32.test(str)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user