List Info

Thread: Validators in a model's validator_list (m-r)




Validators in a model's validator_list (m-r)
user name
2006-04-25 15:18:41
Christian Schneider wrote:
> On 4/25/06, Michael Radziej <mirnoris.de> wrote:
>>
>> Christian Schneider wrote:
>>> Michael,
>>>
>>> I'm still using a generic view. I played with
some custom functions
>> before
>>> and they were called so I'd hoped that it
would work with the validator
>>> objects as well.
>> I looked in the source. Aha! First parameter to
RequiredIfOtherField is
>> the *name* of the field (a string, not a field).
>>
>> Please try and report ...
> 
> 
> nothing's happening, :-(
> 
> Even if it worked would validation stop if the
referenced field didn't have
> the required value? That is: Field 1 is required when
field 2 has value "x"
> and field 2's value is "y". Field 1 is
blank which it should be allowed to
> but would validation stop after evaluating the
RequiredIfOtherField
> validator runs (if it even runs first)?

I don't know what you mean with "stop". I think
each validator will be
executed, but they will take into account whether
record_type has the
right value.

Anyway, I personally give up :-(

You can try to find out what's happening:

- create your own validator that always raises a
ValidationError (see in
the sources for core.validators to see how)
- add this to your validator list
- do you get a validation message?
  - if not, do something like "raise Blablabla"
which should immediately
result in a backtrace when called. What's happening now?
  - else, change the source of core.validators in Django;
raise
Blablabla in the __call__() method. Do you get the error
message?


You get the picture ...

Hope that helps a little bit.

I created a ticket to add documentation for this module
(#1680)


Michael


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Validators in a model's validator_list (m-r)
user name
2006-04-26 08:37:38
Good morning,

On 4/25/06, Michael Radziej <noris.de">mirnoris.de&gt; wrote:

I don't know what you mean with "stop". I think each validator will be
executed, but they will take into account whether record_type has the
right value.

Anyway, I personally give up :-(

You can try to find out what's happening:

- create your own validator that always raises a ValidationError (see in
the sources for core.validators to see how)
- add this to your validator list
- do you get a validation message?

yes but only if I allow the field to be blank.
&nbsp;
 &nbsp;- else, change the source of core.validators in Django; raise
Blablabla in the __call__() method. Do you get the error message?

yes, because I finally found out what the main problem was:

I specified the value to be 2 while it really is "2&quot;. As far as scripting languages go, I'm coming from Perl and didn't even think about running into conversion problems. Anyway, I think it is documented that all values in validators are still strings so my bad.

Thanks a lot

chris

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users"; group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to django-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )