def _validate_type(self, value, schema, constraint, path): if isinstance(constraint, list): for possible_type in constraint: if self._validate_type(value, schema, possible_type, path) is None: return None return f'it is not one of {str(constraint).replace("None", "null")}' elif constraint == 'object': if not is_object(value): return 'it is not an object.' elif constraint == 'array': if not is_array(value): return 'it is not an array.' elif constraint == 'string': if not is_string(value): return 'it is not a string.' elif constraint == 'integer': if not is_integer(value): return 'it is not an integer.' elif constraint == 'number': if not is_number(value): return 'it is not a number.' elif constraint == 'boolean': if not is_boolean(value): return 'it is not a boolean.' elif constraint == 'null' or constraint is None: if value is not None: return 'it is not null.'
def test_is_array(self): assert is_array(True) is False assert is_number(False) is False assert is_array(0) is False assert is_array(0.0) is False assert is_array('Bob') is False assert is_array([1]) is True assert is_array((1,)) is False assert is_array({}) is False