

def clean(self):
    cleaned_data = super(AddL3PolicyForm, self).clean()
    if self.is_valid():
        ipversion = int(cleaned_data['ip_version'])
        subnet_prefix_length = int(cleaned_data['subnet_prefix_length'])
        msg = _('Subnet prefix out of range.')
        if ((ipversion == 4) and (subnet_prefix_length not in range(2, 31))):
            raise forms.ValidationError(msg)
        if ((ipversion == 6) and (subnet_prefix_length not in range(2, 128))):
            raise forms.ValidationError(msg)
    return cleaned_data

dataset/ETHPy150Open openstack/group-based-policy-ui/gbpui/panels/network_policy/forms.py AddL3PolicyForm.clean/original