def clean_username(self): username = self.cleaned_data['username'] if len(username) == 0: raise forms.ValidationError("Invalid username or password")
def clean_email(self): email = self.cleaned_data['email'] validate_email(self.cleaned_data['email']) if email_present(email): raise forms.ValidationError("That email is already used.") return email
def clean_password2(self): if "password1" in self.cleaned_data and "password2" in self.cleaned_data: if self.cleaned_data["password1"] != self.cleaned_data["password2"]: raise forms.ValidationError(_("You must type the same password each time.")) return self.cleaned_data["password2"]
def check_template(self, data): try: Template(data).render(Context({})) except TemplateSyntaxError, err: raise forms.ValidationError(err)
def clean_email(self): email = self.cleaned_data.get('email') User = get_user_model() if User.Objects.filter(email=email).exists(): raise forms.ValidationError('이미 등록된 이메일 입니다.') return email
def clean_field(self, field): value = self.cleaned_data.get(field, None) status = int(self.data.get('status', '0')) if status == Order.STATUS_COLLECTED and not value: raise forms.ValidationError("Отсутствует {}".format(self.fields[field].label.split(',')[0].lower())) return value
def clean_OTP(self): OTP = self.cleaned_data['OTP'] if OTP == self.gen_code: return OTP else: raise forms.ValidationError(_("Invalid code"), code="Invalid OTP")
def clean_password2(self): password1 = self.cleaned_data.get('password1') password2 = self.cleaned_data.get('password2') if password1 and password2 and password1 != password2: raise forms.ValidationError("Passwords do not match") return password2
def clean_email(self): email = self.cleaned_data.get("email") user_count = User.objects.filter(email=email).count() if user_count > 0: raise forms.ValidationError("This email has already been registered, please check and try again or reset your password") return email
def clean(self): cleaned_data = super(BaseCRUDForm, self).clean() if not self.crud_manager.is_valid(self.existing_object, **cleaned_data): raise forms.ValidationError("This item already exists.") return cleaned_data
def clean_email(self): v = self.cleaned_data["email"] if User.objects.filter(email=v).exists(): raise forms.ValidationError("%s is not available" % v) return v
def clean_email(self): email = self.cleaned_data.get("email") if 'email' in self.changed_data: if User.objects.filter(email=email).exists(): raise forms.ValidationError("El email ya está registrado, pruebe con otro.") return email
def clean(self): for person_dict in self.cleaned_data: person = person_dict.get('id') alive = person_dict.get('alive') if person and alive and person.name == "Grace Hopper": raise forms.ValidationError("Grace is not a Zombie")
def clean_password(self): password = self.cleaned_data['password'] if len(password) == 0: raise forms.ValidationError("Invalid username or password")
def clean_article(self): article = self.cleaned_data['article'] if article and Product.objects.filter(article=article).exclude(pk=self.instance.pk).exists(): raise forms.ValidationError("Такой код 1С уже используется") return article
def clean_password2(self): password1 = self.cleaned_data.get('password') password2 = self.cleaned_data.get('password2') if password1 and password2 and password1 != password2: raise forms.ValidationError('password fields didnot match')
def clean_box(self): box = self.cleaned_data.get('box', None) status = int(self.data.get('status', '0')) if status == Order.STATUS_COLLECTED and not box: raise forms.ValidationError("Не выбрана коробка") return box
def clean_username(self): #для того что бы проверить есть ли такой же юзернейм который он создал username = self.cleaned_data.get('username') if User.objects.filter(username=username).exists(): raise forms.ValidationError('Пользоватдлеь с таким юзером, существует') return username
def clean_store(self): store = self.cleaned_data.get('store', None) if self.cleaned_data['status'] == Order.STATUS_DELIVERED_SHOP and store is None: raise forms.ValidationError("Не указан магазин доставки!") return store
def clean(self): cleaned_data = super(TestForm, self).clean() raise forms.ValidationError( "This error was added to show the non field errors styling.") return cleaned_data
def clean(self): cleaned_data = super(UpdateForm, self).clean() if not (cleaned_data.get("new_name") or cleaned_data.get("new_address")): raise forms.ValidationError("Either a new name or new address is required.") return cleaned_data
def clean_password(self): password = self.cleaned_data.get("password","") if password and len(password) < 6: raise forms.ValidationError("密码不能少于6位") return password
def clean_nickname(self): nickname = self.cleaned_data.get('nickname') if Profile.Objects.filter(nickname=nickname).exists(): raise forms.ValidationError('이미 사용중인 닉네임 입니다.') return nickname
def clean_password2(self): cd = self.cleaned_data if cd['password'] != cd['password2']: raise forms.ValidationError('Passwords don\'t match.') return cd['password2']
def clean_username(self): username = self.cleaned_data['username'] if username_present(username): raise forms.ValidationError("That username is taken") return username
def clean_confirm_password(self): cd = self.cleaned_data if cd['new_password'] != cd['confirm_password']: raise forms.ValidationError('Passwords don\'t match.') return cd['confirm_password']
def clean_oldpassword(self): if not self.user.check_password(self.cleaned_data.get("oldpassword")): raise forms.ValidationError(_("Please type your current password.")) return self.cleaned_data["oldpassword"]
def check_for_z(value): if value[0].lower() != 'z': raise forms.ValidationError('NAME NEEDS TO START WITH Z')
def clean_email(self): email = self.cleaned_data.get('email') username = self.cleaned_data.get('username') if User.objects.filter(email=email).exclude(username=username): raise forms.ValidationError("Email address must be unique") return email
def clean_honeypot(self): honeypot = self.cleaned_data['honeypot'] if len(honeypot): raise forms.ValidationError("honeypot should be left empty")