def validate_label(self, value): if not ContactField.is_valid_label(value): raise serializers.ValidationError("Can only contain letters, numbers and hypens.") key = ContactField.make_key(value) if not ContactField.is_valid_key(key): raise serializers.ValidationError("Generated key \"%s\" is invalid or a reserved name." % key) return value
def validate_label(self, value): if not ContactField.is_valid_label(value): raise serializers.ValidationError("Can only contain letters, numbers and hypens.") key = ContactField.make_key(value) if not ContactField.is_valid_key(key): raise serializers.ValidationError("Generated key \"%s\" is invalid or a reserved name." % key) return value
def clean(self): for key in self.cleaned_data: if key.startswith('field_'): idx = key[6:] label = self.cleaned_data["label_%s" % idx] if label: if not ContactField.is_valid_label(label): raise forms.ValidationError(_("Field names can only contain letters, numbers, spaces and hypens")) elif label in RESERVED_CONTACT_FIELDS: raise forms.ValidationError(_("Field name '%s' is a reserved word") % label) return self.cleaned_data
def clean(self): # don't allow users to specify field keys or labels re_col_name_field = re.compile(r'column_\w+_label') for key, value in self.data.items(): if re_col_name_field.match(key): field_label = value field_key = slugify_with(value) if not ContactField.is_valid_label(field_label): raise ValidationError(_("Field names can only contain letters, numbers, spaces and hypens")) if field_key in RESERVED_CONTACT_FIELDS: raise ValidationError(_("%s is a reserved name for contact fields") % value) return self.cleaned_data
def clean(self): # don't allow users to specify field keys or labels re_col_name_field = re.compile(r'column_\w+_label') for key, value in self.data.items(): if re_col_name_field.match(key): field_label = value field_key = slugify_with(value) if not ContactField.is_valid_label(field_label): raise ValidationError(_("Field names can only contain letters, numbers, spaces and hypens")) if field_key in RESERVED_CONTACT_FIELDS: raise ValidationError(_("%s is a reserved name for contact fields") % value) return self.cleaned_data
def clean(self): for key in self.cleaned_data: if key.startswith('field_'): idx = key[6:] label = self.cleaned_data["label_%s" % idx] if label: if not ContactField.is_valid_label(label): raise forms.ValidationError( _("Field names can only contain letters, numbers, spaces and hypens" )) elif label in RESERVED_CONTACT_FIELDS: raise forms.ValidationError( _("Field name '%s' is a reserved word") % label) return self.cleaned_data
def clean(self): used_labels = [] for key in self.cleaned_data: if key.startswith('field_'): idx = key[6:] label = self.cleaned_data["label_%s" % idx] if label: if not ContactField.is_valid_label(label): raise forms.ValidationError(_("Field names can only contain letters, numbers and hypens")) if label.lower() in used_labels: raise ValidationError(_("Field names must be unique")) elif label in Contact.RESERVED_FIELDS: raise forms.ValidationError(_("Field name '%s' is a reserved word") % label) used_labels.append(label.lower()) return self.cleaned_data
def validate_label(self, value): if value and not ContactField.is_valid_label(value): raise serializers.ValidationError( "Field can only contain letters, numbers and hypens") return value
def validate_label(self, value): if value and not ContactField.is_valid_label(value): raise serializers.ValidationError("Field can only contain letters, numbers and hypens") return value