docs: def validate(self, value, redis):
          '''
          Validates data obtained from a request and returns it in the apropiate
          format
          '''
          # cleanup
          if type(value) == str:
              value = value.strip()
  
          value = self.value_or_default(value)
  
          # validation
          self.validate_required(value)
  
          if self.regex and not re.match(self.regex, value, flags=re.ASCII):
              raise InvalidFieldError(self.name)
  
          if self.forbidden and value in self.forbidden:
              raise ReservedFieldError(self.name)
  
          if self.allowed and value not in self.allowed:
              raise InvalidFieldError(self.name)
  
          if self.index:
              key = self.key()
  
              old = debyte_string(redis.hget(key, value))
              old_value = getattr(self.obj, self.name)
  
              if old is not None and old != self.obj.id:
                  raise NotUniqueFieldError(self.name)
              elif old_value != value:
                  self.obj._old[self.name] = old_value
  
          return value