Previously, the widgets were validating the phone number, leaving no room for the django regular validation procedure. If you performed custom validation on PhoneNumberFields, see the migration guide below.
Previously, the widgets handled part of the validation. That behavior prevents overriding validation in form fields, as widgets were casting the value into a PhoneNumber object, validating it in the process.
Following the MultiValueField implementation from Django (and MultiWidget), the widget now handles the presentation logic, but makes
no attempt at validation. The new SplitPhoneNumberField handles the logic of validating the region choice and the number, and the PhoneNumberPrefixWidget simply dispatches the region and number data to the appropriate widget.
In order to retain backward compatibility, now that the validate_international_phonenumber actually comes into play, its error code has been changed to invalid, so that the custom error message for invalid shows.
validate_international_phonenumber
Review uses of the invalid_phone_number error code. You’ll probably want to replace them with invalid. Given that the validator usually did not come into play, you shouldn’t find many uses.
PhoneNumberField with RegionalPhoneNumberWidget
Move the custom validation occurs in the Django Formclean_FIELD() (or clean()), and no changes should be noticeable.
PhoneNumberField with PhoneNumberPrefixWidget
Use the SplitPhoneNumberField instead. Error messages will change slightly and should be more precise (whether the region is not part of
the choices, or the number cannot be interpreted in the selected region).
For more examples, take a look at tests.test_formfields.SplitPhoneNumberFieldTest.
Make sure GitHub loads the diff for file tests/test_formfields.py
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Bumps django-phonenumber-field from 7.3.0 to 8.0.0.
Release notes
Sourced from django-phonenumber-field's releases.
Commits
f7765f4
docs: Fix representation of serializerb255326
Add validate_phonenumber to allow short numbersb8d1886
Rename test_value_from_datadict to test_example_numbers9923578
Move validation from widgets to the form fieldse491d09
Drop support for Django 4.1ef1e728
Remove PhoneNumberInternationalFallbackWidgetDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show