Opened 3 months ago

Last modified 3 weeks ago

#35693 assigned Cleanup/optimization

Password validators aren't callable

Reported by: iamkorniichuk Owned by: iamkorniichuk
Component: contrib.auth Version: dev
Severity: Normal Keywords: validators password callable
Cc: iamkorniichuk Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

By default validating fields use this syntax validator(value) but password validators don't implement .__call__(). Therefore making them unusable outside of validate_password().
This is small change doesn't change any behavior but add support for intuitive approach to password validators.

Change History (3)

comment:1 by iamkorniichuk, 3 months ago

I think it will be enough to add such a method to django.contrib.auth.password_validation classes:

def __call__(self, *args, **kwargs):
    return self.validate(*args, **kwargs)

comment:2 by Natalia Bidart, 3 months ago

Keywords: validators added; validator validator removed
Needs documentation: set
Needs tests: set
Owner: set to iamkorniichuk
Status: newassigned
Triage Stage: UnreviewedAccepted
Version: 5.1dev

Thank you iamkorniichuk for creating this ticket.

As I mentioned in your PR, I agree that the inconsistency between the django.core.validators providing __call__ but password validators not providing it feels off. Accepting on that basis, also I couldn't find a previous conversation or request about this issue.

Please note that the PR definitely needs tests and docs updates, besides a small release note for 5.2.

Good luck!

comment:3 by Antoliny, 3 weeks ago

Can I work on this ticket?

Note: See TracTickets for help on using tickets.
Back to Top