summaryrefslogtreecommitdiff
path: root/src/node_modules/validator/es/lib/toBoolean.js
blob: 25e1eac799502c4ee26d4ee02c5f06fbe09e8b68 (plain)
1
2
3
4
5
6
7
8
9
10
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 !== '';
}