#31461: Make it easier to customize ValidationError messages in
contrib.auth.password_validation
-------------------------------------+-------------------------------------
     Reporter:  Joey van Breukelen   |                    Owner:  Joey van
         Type:                       |  Breukelen
  Cleanup/optimization               |                   Status:  closed
    Component:  contrib.auth         |                  Version:  3.0
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * status:  assigned => closed
 * resolution:   => wontfix


Comment:

 Hi. Thanks for the report.

 I'm going to say no initially.

 The trade off here is a whole extra method/hook in order to save very
 little code.

 The whole method is just this:


 {{{
     def validate(self, password, user=None):
         if len(password) < self.min_length:
             raise ValidationError(
                 ngettext(
                     "This password is too short. It must contain at least
 %(min_length)d character.",
                     "This password is too short. It must contain at least
 %(min_length)d characters.",
                     self.min_length
                 ),
                 code='password_too_short',
                 params={'min_length': self.min_length},
             )

 }}}

 Do, the check, raise the `ValidationError`. That's it.

 The "Writing your own validator" docs have it like so:

 > If Django's built-in validators are not sufficient, you can write your
 own
 > password validators. Validators have a fairly small interface. They must
 > implement two methods:...

 I'm not convinced custom messages are such a common need to merit making
 that **three** methods.
 (Although I guess the extra hook would be internal, but still...)

 I hope that makes sense.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31461#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.a709568a6cf22a6f50fbf3d4854f444e%40djangoproject.com.

Reply via email to