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
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
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
def clean_phone(self): phone = normalize_phone(self.cleaned_data['phone']) return phone
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
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
def validate_phone(self, value): value = normalize_phone(value) return value
def validate_phone(value): value = normalize_phone(value) if len(value) != 12: raise ValidationError(_('Format error.')) return value