How to use the fireo.fields.errors.InvalidFieldType function in fireo

To help you get started, we’ve selected a few fireo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github octabytes / FireO / src / fireo / fields / number_field.py View on Github external
def db_value(self, val):
        if type(val) in [int, float, Increment] or val is None:
            return val
        raise errors.InvalidFieldType(f'Invalid field type. Field "{self.name}" expected {int} or {float}, '
                                      f'got {type(val)}')
github octabytes / FireO / src / fireo / fields / map_field.py View on Github external
def db_value(self, val):
        if type(val) is dict or val is None:
            # check if user defined to set the value as lower case
            if self.model_cls._meta.to_lowercase:
                return {k: v.lower() if type(v) is str else v for k,v in val.items()}
            return val
        raise errors.InvalidFieldType(f'Invalid field type. Field "{self.name}" expected {dict}, '
                                      f'got {type(val)}')
github octabytes / FireO / src / fireo / fields / boolean_field.py View on Github external
def db_value(self, val):
        if type(val) is bool or val is None:
            return val
        raise errors.InvalidFieldType(f'Invalid field type. Field "{self.name}" expected {bool}, '
                                      f'got {type(val)}')
github octabytes / FireO / src / fireo / fields / data_time.py View on Github external
def db_value(self, val):
        if any([
            isinstance(val, DatetimeWithNanoseconds),
            isinstance(val, datetime),
            isinstance(val, Sentinel),
            isinstance(val, type(None)),
        ]):
            return val
        raise errors.InvalidFieldType(f'Invalid field type. Field "{self.name}" expected {datetime}, '
                                      f'got {type(val)}')
github octabytes / FireO / src / fireo / fields / number_field.py View on Github external
def attr_float_only(self, attr_val, field_val):
        """Method for attribute float_only"""
        if attr_val and type(field_val) is not float:
            raise errors.InvalidFieldType(f'Invalid field type. Field "{self.name}" expected {float} type, '
                                          f'got {type(field_val)}')
        return field_val
github octabytes / FireO / src / fireo / fields / list_field.py View on Github external
def db_value(self, val):
        if type(val) in [list, ArrayUnion, ArrayRemove] or val is None:
            # check if user defined to set the value as lower case
            if self.model_cls._meta.to_lowercase:
                return [v.lower() if type(v) is str else v for v in val]
            return val
        raise errors.InvalidFieldType(f'Invalid field type. Field "{self.name}" expected {list}, '
                                      f'got {type(val)}')