Esempio n. 1
0
    def clean_phone(self):
        phone = self.cleaned_data['phone']
        phone = normalize_phone(phone)
        if not User.objects.filter(phone=phone).exists():
            raise forms.ValidationError(_('User with phone number {phone} does not exist').format(phone=phone))

        return phone
Esempio n. 2
0
 def clean(self):
     cleaned_data = super().clean()
     User = get_user_model()
     phone = cleaned_data.get('phone', '')
     if not phone:
         raise forms.ValidationError(_('Please, provide phone number'))
     cleaned_data['phone'] = normalize_phone(phone)
     code = cleaned_data.get('code', '')
     if not code or not User.objects.filter(phone=phone, activation_code=code, is_active=False).exists():
         raise forms.ValidationError(_('Account not found'))
     return cleaned_data
Esempio n. 3
0
 def clean(self):
     cleaned_data = super().clean()
     User = get_user_model()
     phone = cleaned_data.get('phone', '')
     if not phone:
         raise forms.ValidationError(_('Phone is required'))
     phone = normalize_phone(phone)
     cleaned_data['phone'] = phone
     code = cleaned_data.get('code', '')
     if not code or not User.objects.filter(phone=phone, activation_code=code).exists():
         raise forms.ValidationError(_('Account not found'))
     return cleaned_data
Esempio n. 4
0
 def clean_phone(self):
     phone = normalize_phone(self.cleaned_data['phone'])
     return phone
Esempio n. 5
0
 def clean_phone(self):
     User = get_user_model()
     phone = normalize_phone(self.cleaned_data['phone'])
     if not User.objects.filter(phone=phone, is_active=False).exists():
         raise forms.ValidationError(_('Account not found'))
     return phone
Esempio n. 6
0
 def validate_phone(self, value):
     phone = normalize_phone(value)
     if len(phone) != 12:
         raise serializers.ValidationError(
             _('The value is not correct phone number.'))
     return phone
Esempio n. 7
0
 def validate_phone(self, value):
     value = normalize_phone(value)
     return value
Esempio n. 8
0
def validate_phone(value):
    value = normalize_phone(value)
    if len(value) != 12:
        raise ValidationError(_('Format error.'))
    return value