CoastalCommitsPastes/server/node_modules/validator/es/lib/toBoolean.js
2022-03-06 16:46:59 -08:00

10 lines
No EOL
249 B
JavaScript

import assertString from './util/assertString';
export default function toBoolean(str, strict) {
assertString(str);
if (strict) {
return str === '1' || /^true$/i.test(str);
}
return str !== '0' && !/^false$/i.test(str) && str !== '';
}