Validate a value to be boolean. Defaults to `def`.  Raises an exception with `context[name]` when not a boolean.
358558
function validateNumber(context, name, def) {
  var value = context[name]

  if (value == null) {
    value = def
  }

  if (isNaN(value)) {
    raise(value, 'options.' + name)
  }

  context[name] = value
}
251196
protected Boolean checkBoolean(Object val, Boolean def) {
        return (val == null) ? def : (Boolean) val;
    }
795380
def to_boolean_with_default(value, default_value):
        
        result = BooleanConverter.to_nullable_boolean(value)
        return result if result != None else default_value
55991
def validate(self, data, all_data=None):
        '''
        
        '''
        if data is None:
            return True, False
        else:
            return super(BooleanField, self).validate(data, all_data)
1323121
def convert_boolean(value, parameter, default=False):
    '''
    
    '''
    value = _check_default(value, parameter, ( '', '-', None ))
    if isinstance(value, bool):
        return value
    if isinstance(value, str) and len(value) > 0:
        value = value[0]
    return value not in ( 'f', 'F', '0', False, None )
981046
def _get_bool_val(self, name):
        
        element = getattr(self, name)
        if element is None:
            return None
        return element.val
1166729
def get_bool_attr(self, name):
    
    val = self.get_attr(name)
    return val is not None and val.lower() in ("true", name)
266459
def truth(val, context):
    
    try:
        0 + val
    except TypeError:
        lower_val = val.lower()

        if lower_val in TRUE:
            return True
        elif lower_val in FALSE:
            return False
        else:
            raise FilterError("Bad boolean value %r in %r (expected one of '%s', or '%s')" % (
                val, context, "' '".join(TRUE), "' '".join(FALSE)
            ))
    else:
        return bool(val)
874146
def truthy(value):
    
    if value is None or value == '':
        return False
    value = str(value)
    try:
        return (int(value) != 0)
    except:
        pass
    return (truthy_true_yes.match(value) is not None)
1142666
function boolean(value) {
  var parsedBoolean = json(value);

  // handle 0|1 case
  if (typeOf(parsedBoolean) == 'number' && [0, 1].indexOf(parsedBoolean) > -1) {
    parsedBoolean = parsedBoolean === 0 ? false : true;
  }

  // couldn't parse it
  if (typeOf(parsedBoolean) != 'boolean') {
    return throwModifierError('boolean', value, {message: 'Invalid Boolean'});
  }

  return parsedBoolean;
}
662444
def validate(cls, value):
        
        if value not in cls._valid_settings:
            raise ValueError(
                "%s not a member of %s enumeration" % (value, cls.__name__)
            )
587984
function toBoolean(val, def) {
    if (is_1.isBoolean(val))
        return val;
    if (!is_1.isValue(val))
        return toDefault(null, def);
    val = val.toString();
    return (parseFloat(val) > 0 ||
        is_1.isInfinite(val) ||
        val === 'true' ||
        val === 'yes' ||
        val === '1' ||
        val === '+');
}
464968
def coerce(value):
        
        if isinstance(value, BoolCell):
            return value
        elif isinstance(value, Cell):
            raise CellConstructionFailure("Cannot convert %s to BoolCell" % \
                    type(value))
        elif value in [1, T]:
            return BoolCell(T)
        elif value in [0, -1, F]:
            return BoolCell(F)
        elif value in [None, U]:
            return BoolCell(U)
        else:
            raise CoercionFailure("Don't know how to coerce %d to Bool" % \
                    (value))
914946
def _parse_bool(value):
    """"""
    if isinstance(value, bool):
        return value

    elif isinstance(value, str):
        if value == 'True':
            return True
        elif value == 'False':
            return False

    raise Exception("Value %s is not boolean." % value)
112360
def validate(self, value):
        """"""
        if value is not None and not isinstance(value, bool):
            raise ValidationError("field must be a boolean")

        super().validate(value)
371124
def validate_boolean_or_string(option, value):
    """"""
    if isinstance(value, string_type):
        if value not in ('true', 'false'):
            raise ValueError("The value of %s must be "
                             "'true' or 'false'" % (option,))
        return value == 'true'
    return validate_boolean(option, value)
295882
function validateFunction(context, name, def) {
  var value = context[name]

  if (value == null) {
    value = def
  }

  if (typeof value !== 'function') {
    raise(value, 'options.' + name)
  }

  context[name] = value
}