from django.contrib.auth.forms import PasswordResetForm
from django.contrib.auth.models import User
from django import forms

class CustomPasswordResetForm(PasswordResetForm):
    """Custom password reset form that validates email existence."""
    
    def clean_email(self):
        """Validate that the email exists in our database."""
        email = self.cleaned_data['email']
        if not User.objects.filter(email=email).exists():
            raise forms.ValidationError("There is no user registered with this email address.")
        return email
