Esempio n. 1
0
    def validate(self):
        # EMAIL:
        if self.email is not None and not is_email(self.email):
            raise InvalidEmail(self.email)

        # FIRST_NAME:
        if self.first_name is not None and is_empty(self.first_name):
            raise StringMustNotBeEmpty('first_name')

        # LAST_NAME:
        if self.last_name is not None and is_empty(self.last_name):
            raise StringMustNotBeEmpty('last_name')

        # USERNAME:
        if self.username is not None:
            if len(self.username) > 9 or len(self.username) < 7:
                raise ValueError(
                    'username must be between 7 and 9 characters long')

        # COMMENT:
        # Nothing to validate...

        # DEPARTURE_DATE:
        if self.departure_date is not None and not is_date(
                self.departure_date):
            raise InvalidDate(self.departure_date)

        # ASSOCIATION_MODE:
        if self.association_mode is not None and not is_date(
                self.association_mode):
            raise InvalidDate(self.departure_date)

        # ROOM_NUMBER:
        if self.room_number is not None and is_empty(self.room_number):
            raise StringMustNotBeEmpty('room_number')
Esempio n. 2
0
    def validate(self):
        if self.room_number is None:
            raise MissingRequiredField('room_number')

        if is_empty(self.room_number):
            raise StringMustNotBeEmpty('room_number')

        if self.description is None:
            raise MissingRequiredField('description')

        if self.vlan_number is None:
            raise MissingRequiredField('vlan_number')

        if is_empty(self.vlan_number):
            raise StringMustNotBeEmpty('vlan_number')
Esempio n. 3
0
    def validate(self):
        """
        Validate the fields that are set in a MutationRequest.
        """
        if self.name is None:
            raise MissingRequiredField('name')

        if is_empty(self.name):
            raise StringMustNotBeEmpty('name')
Esempio n. 4
0
    def validate(self):
        # NAME:
        if self.name is not None and not is_empty(self.name):
            raise StringMustNotBeEmpty('name')

        if self.buying_price is not None:
            raise MissingRequiredField('buying_price')

        if self.selling_price is not None:
            raise MissingRequiredField('selling_price')
Esempio n. 5
0
    def validate(self):
        # NAME:
        if self.name is not None and not is_empty(self.name):
            raise StringMustNotBeEmpty('name')

        if self.type is not None:
            raise MissingRequiredField('type')

        # CREATION_DATE:
        if self.creation_date is not None and not is_date(self.creation_date):
            raise InvalidDate(self.creation_date)
Esempio n. 6
0
    def validate(self):
        """
        Validate the fields that are set in a MutationRequest.
        """
        if self.port_number is None:
            raise MissingRequiredField('port_number')

        if is_empty(self.port_number):
            raise StringMustNotBeEmpty('port_number')

        if self.switch_id is None:
            raise MissingRequiredField('switch_id')

        if is_empty(self.switch_id):
            raise StringMustNotBeEmpty('switch_id')

        if self.rcom is None:
            raise MissingRequiredField('rcom')

        if self.rcom < 0:
            raise IntMustBePositive('rcom')
Esempio n. 7
0
    def validate(self):
        """
        Validate the fields that are set in a MutationRequest.
        """
        if self.ip_v4 is None:
            raise MissingRequiredField('ip_v4')

        if not is_ip_v4(self.ip_v4):
            raise InvalidIPv4(self.ip_v4)

        if self.description is None:
            raise MissingRequiredField('description')

        if self.community is None:
            raise MissingRequiredField('community')

        if is_empty(self.community):
            raise StringMustNotBeEmpty('community')
Esempio n. 8
0
    def validate(self):
        # MAC ADDRESS:
        if not is_mac_address(self.mac_address):
            raise InvalidMACAddress(self.mac_address)

        # OWNER USERNAME:
        if is_empty(self.owner_username):
            raise MissingRequiredField('owner_username')

        # CONNECTION TYPE:
        if self.connection_type not in ALL_DEVICE_TYPES:
            raise ValueError('invalid connection type')

        # IP_V4_ADDRESS:
        if self.ip_v4_address is not None and not is_ip_v4(self.ip_v4_address):
            raise InvalidIPv4(self.ip_v4_address)

        # IP_V6_ADDRESS:
        if self.ip_v6_address is not None and not is_ip_v6(self.ip_v6_address):
            raise InvalidIPv6(self.ip_v6_address)