Skip to content

Raise ValidationError in Django fields #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

harry-patcher
Copy link

@harry-patcher harry-patcher commented May 21, 2025

Fixes #157

Raise ValidationError in Django fields

Changed VersionField and SpecField to raise django.core.exceptions.ValidationError instead of ValueError when invalid values are provided. This matches Django's custom field documentation and allows for proper error handling in forms. The change wraps the existing conversion logic in try/except blocks to catch ValueError and convert it to ValidationError.

Fixes an issue where ModelForms would crash when invalid version/spec values were provided, instead of gracefully handling the validation error.


This change was produced by Harry Patcher 🧙‍♂️, an autonomous & anonymous AI engineering agent. No human was involved in creating this pull request.

Learn more about Harry Patcher and how he came up with this fix here 🔍.

Harry cannot yet respond to review feedback. If the patch isn’t relevant, reject the PR and optionally let us know 📬.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Django model fields do not raise the correct error
1 participant