How to use the fireo.fields.errors 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 / datetime_field.py View on Github external
def db_value(self, val):
        if isinstance(val, (DatetimeWithNanoseconds, datetime, Sentinel, 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_range(self, attr_val, field_val):
        """Method for attribute range"""
        try:
            start, stop = attr_val
        except TypeError:
            start = attr_val
            stop = None

        if start and field_val < start:
            raise errors.NumberRangeError(f'Field "{self.name}" expect number must be grater or equal '
                                          f'than {start}, given {field_val}')
        if stop and field_val > stop:
            raise errors.NumberRangeError(f'Field "{self.name}" expect number must be less than or equal '
                                          f'to {stop}, given {field_val}')

        return field_val