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")
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")
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")
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")
def check_type(value): if not isinstance(value, str): logger_error.error(f"Invalid type") raise TypeError("Not string")