Ejemplo n.º 1
0
    def test_UtilIsOnlyDigits(self):

        number = "07464393"
        self.assertTrue(Util.isOnlyDigits(number))

        number = "fjfkg99"
        self.assertFalse(Util.isOnlyDigits(number))
Ejemplo n.º 2
0
    def validate(contact):
        """
        Validates a contact, throws ValidationException if incorrect data.
        """

        msg = ""

        if contact.name is "" or None:
            msg += "Name cannot be empty."
        if not contact.group in VALID_GROUPS:
            msg += "Not a valid group."
        if contact.phoneNr is "" or None:
            msg += "Phone nr cannot be null."
        if not Util.isOnlyDigits(contact.phoneNr):
            msg += "Phone nr can only be digits."

        if msg:
            raise ValidationException(msg)