Code

Opened 7 years ago

Closed 7 years ago

#3250 closed enhancement (wontfix)

[patch] Add RequiredIfOtherFieldsNotGiven, RequiredIfAllOtherFieldsNotGiven, and AllValidators

Reported by: exogen@… Owned by: adrian
Component: Validators Version: master
Severity: normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In the Validators documentation there claims to be a RequiredIfOtherFieldsNotGiven, but it doesn't actually exist. This implements the documented semantics and also introduces two supporting validators.

RequiredIfAllOtherFieldsNotGiven: Like the one mentioned above, but fails only when all of the other fields are not given (instead of any).
AllValidators: Like AnyValidator, but passes only when all of the given validators pass.

Attachments (2)

brian_validators.diff (2.5 KB) - added by exogen@… 7 years ago.
adds validators mentioned in #3250
brian_tests.py (2.0 KB) - added by exogen@… 7 years ago.
doctests for validators added in #3250

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by exogen@…

adds validators mentioned in #3250

Changed 7 years ago by exogen@…

doctests for validators added in #3250

comment:1 Changed 7 years ago by Matt

The patch attached here overlaps with the patch on ticket #2266.

The patch on ticket #2266 adds RequiredIfOtherFieldsNotGiven (with tests and updated docs) while this ticket offers RequiredIfOtherFieldsNotGiven and a new RequiredIfAllOtherFieldsNotGiven validators with tests but no docs.

Should we merge the tickets and flag one as a duplicate?

comment:2 follow-up: Changed 7 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Ready for checkin

My thoughts:

  • take the RequiredIfOtherFieldsNotGiven from #2266
  • take the RequiredIfOtherFieldsNotGiven and RequiredIfAllOtherFieldsNotGiven from here.

comment:3 in reply to: ↑ 2 Changed 7 years ago by David Chandek-Stark <david.chandek.stark@…>

Replying to Simon G. <dev@simon.net.nz>:

My thoughts:

  • take the RequiredIfOtherFieldsNotGiven from #2266
  • take the RequiredIfOtherFieldsNotGiven and RequiredIfAllOtherFieldsNotGiven from here.

Did you mean "take AllValidators and RequiredIfAllOtherFieldsNotGiven from here"?

In any case, I'd love to see these patches released soon.

Thanks!

comment:4 Changed 7 years ago by ubernostrum

Hmm.

Might be tough to justify adding more functionality to the manipulator system just as we're deprecating it...

comment:5 Changed 7 years ago by mtredinnick

  • Resolution set to wontfix
  • Status changed from new to closed

Since the validator functions primarily exist to support the oldforms part of the framework, we aren't adding any extra functionality to it now. It's deprecated. The fact that validators can also be used in model fields is kind of a side-effect and some model-aware validation changes will slowly phase that out, too.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.