예제 #1
0
 def clean_text(self):
     data = self.cleaned_data['text']
     if data == '':
         raise forms.ValidationError("Поле обязательно для заполнения")
     return data
예제 #2
0
 def clean_phone_number(self):
     phone_number = self.cleaned_data.get('phone_number',
                                          '').replace(' ', '')
     if not self.phone_number_regex.match(phone_number):
         raise forms.ValidationError(_('Please enter an UK phone number'))
     return phone_number
예제 #3
0
파일: admin.py 프로젝트: fossabot/Minerva
 def clean_password2(self):
     password1 = self.cleaned_data.get("password1")
     password2 = super(UserCreationForm, self).clean_password2()
     if bool(password1) ^ bool(password2):
         raise forms.ValidationError("Fill out both fields")
     return password2
예제 #4
0
 def clean(self):
     cleaned_data = super(ContactUserIncludingPasswordForm, self).clean()
     if Contact.objects.filter(username=cleaned_data.get("email")).exists():
         raise forms.ValidationError(
             _('An user with the given email already exists'))
     return cleaned_data
 def clean_field_name(self):
     data = self.cleaned_data['Productid']
     if not data:  # 如果data不满足满足条件
         raise forms.ValidationError('data is invalid')
     return data
예제 #6
0
 def clean_country(self):
     code = self.cleaned_data['country']
     if code and (len(code) != 3 or not code.isalpha()):
         raise forms.ValidationError(
             u'Must be three characters (ISO 3166-1):  e.g. USA, CAN, MNG')
     return code.upper()
예제 #7
0
 def clean_description(self):
     description = self.cleaned_data.get("description")
     if not description:
         raise forms.ValidationError( _("This field is required"))
     return description
예제 #8
0
 def check_login_to_unique(self, cleaned_data):
     login = cleaned_data.get('login')
     check_fist_2_letter_for_login = User.objects.filter(username__startswith=login[:2])
     if check_fist_2_letter_for_login:
         mess = u'Логин не подходит уникальность по сокращениям (не уникальны первые 2 сивола логин)'
         raise forms.ValidationError(mess)
예제 #9
0
 def check_email_to_unique(self, cleaned_data):
     email = cleaned_data.get('email')
     check_email_unique = User.objects.filter(email__iexact=email)
     if check_email_unique:
         mess = u'Такой email уже зарегистрирован'
         raise forms.ValidationError(mess)
예제 #10
0
파일: forms.py 프로젝트: anish03/apartment
 def clean_name(self):
     name = self.cleaned_data.get('name')
     if len(name) == 1:
         raise forms.ValidationError('Please enter a valid name')
     return name
예제 #11
0
 def check_passwords(self, cleaned_data):
     password1 = cleaned_data.get('password1')
     password2 = cleaned_data.get('password2')
     if password1 != password2:
         mess = u'Пароли не совпадают'
         raise forms.ValidationError(mess)
예제 #12
0
파일: forms.py 프로젝트: DenNavin/RST
 def clean_password2(self):
     cd = self.cleaned_data
     if cd['password'] != cd['password2']:
         raise forms.ValidationError('Passwords don\'t match.')
     return cd['password2']
예제 #13
0
def AnoValidator(ano):
    if ano < 0 and ano > date.today().year:
        raise forms.ValidationError('Data indisponivel')
    else:
        return ano
예제 #14
0
    def clean_username(self, username, shallow=False):
        if not self.username_regex.match(username):
            raise forms.ValidationError(
                self.error_messages['invalid_username'])

        return username
예제 #15
0
 def clean_hours_of_operation(self):
     hours_of_operation = self.cleaned_data.get("hours_of_operation")
     if not hours_of_operation:
         raise forms.ValidationError(_("This field is required"))
     return hours_of_operation
예제 #16
0
    def valide_date(date):

        if date < datetime.date.today():
            raise forms.ValidationError("The date cannot be in the past!")
        return date
예제 #17
0
 def clean_music(self):
     music = self.cleaned_data.get("music")
     if not music:
         raise forms.ValidationError(_("This music is required"))
     return music
예제 #18
0
 def clean_date(self):
     date = self.cleaned_data['date']
     if date < datetime.date.today():
         raise forms.ValidationError("Sorry, Invalid Date!")
     return date
예제 #19
0
 def clean_time(self):
     time = self.cleaned_data.get("time")
     if not time:
         raise forms.ValidationError( _("This field is required"))
     return time
예제 #20
0
    def clean_qq(self):
        cleaned_data = self.clean_data['qq']
        if not cleaned_data.isdigit():
            raise  forms.ValidationError('必须是数字!')

        return int(cleaned_data)
예제 #21
0
 def clean_image(self):
     image = self.cleaned_data.get("image")
     if not image:
         raise forms.ValidationError( _("This field is required"))
     return image
예제 #22
0
def validate_f_word(content):
    if "f**k" in content.lower():
        raise forms.ValidationError("Can't tweet F word!")
    return content
예제 #23
0
 def clean(self):
     if self.cleaned_data['price'] < 50:
         raise forms.ValidationError(
             message='Цена смартфона должна быть больше 50')
예제 #24
0
 def clean(self):
     print(self.cleaned_data)
     if Category.objects.filter(name=self.cleaned_data.get("name")):
         raise forms.ValidationError(message="Category already exists")
     if len(self.cleaned_data.get("name")) is 0:
         raise forms.ValidationError(message="field is empty")
예제 #25
0
 def clean_date(self):
     date = self.cleaned_data['appointment_date']
     if date < datetime.date.today():
         raise forms.ValidationError("The date cannot be in the past!")
     return date
예제 #26
0
 def clean_address(self):
     address = self.cleaned_data.get("address")
     if not address:
         raise forms.ValidationError(_("This field is required"))
     return address
예제 #27
0
 def __call__(self, value):
     if value.size > self.max_size:
         raise forms.ValidationError(
             _('Maximum allowed size is %(max_size)s') %
             {'max_size': filesizeformat(self.max_size)})
예제 #28
0
 def clean_area(self):
     area = self.cleaned_data.get("area")
     if not area:
         raise forms.ValidationError(_("This field is required"))
     return area
예제 #29
0
    def clean_age(self):
        data = self.cleaned_data['age']
        if data < 18:
            raise forms.ValidationError("Вы слишком молоды!")

        return data
예제 #30
0
 def clean_age(self):
     data = self.cleaned_data['age']
     if data < 18:
         raise forms.ValidationError(
             "Лицам моложе 18-ти лет запрещено регистрироваться на сайте!")
     return data