Ejemplo n.º 1
0
 def __set__(self, instance, value):
     self.check_type(value)
     number = self.check_phone(value)
     if number is not None:
         if self._name in instance.__dict__:
             logger_info.info("Phone was changed")
         instance.__dict__[self._name] = number
     else:
         logger_error.error(f"Invalid number: {value}")
         raise ValueError("Invalid number")
Ejemplo n.º 2
0
    def __set__(self, instance, value):
        self.check_type(value)
        if self.check_date(value):
            tmp = parse(value)
            if self._name in instance.__dict__:
                logger_info.info(f"Date was changed ")
            instance.__dict__[self._name] = tmp

        else:
            logger_error.error(f"Invalid date: {value}")
            raise ValueError("input not str type")
Ejemplo n.º 3
0
 def __set__(self, instance, value):
     self.check_type(value)
     if self.check_name(value):
         if self._name not in instance.__dict__:
             instance.__dict__[self._name] = value
         else:
             logger_error.error(f"Changes Forbidden")
             raise AttributeError("Changes Forbidden")
     else:
         logger_error.error(f"Incorrect Name/Surname {value}")
         raise ValueError("Incorrect Name/Surname")
Ejemplo n.º 4
0
    def __set__(self, instance, value):

        if self._name == "document_id":
            self.check_type(value)
            res = self.check_id(value, DOC_TYPE[instance.document_type])
            if res is not None:
                if self._name in instance.__dict__:
                    logger_info.info("ID was changed")
                instance.__dict__[self._name] = res
            else:
                logger_error.error(f"Invalid id: {value}")
                raise ValueError("Invalid ID")

        elif self._name == "document_type":
            self.check_type(value)
            if self.check_doc(value):
                if self._name in instance.__dict__:
                    logger_info.info("Type was changed")
                instance.__dict__[self._name] = value
            else:
                logger_error.error(f"Invalid document: {value}")
                raise ValueError("Invalid document")
Ejemplo n.º 5
0
 def check_type(value):
     if not isinstance(value, str):
         logger_error.error(f"Invalid type")
         raise TypeError("Not string")