On Nov 23, 2007 3:29 PM, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
>
> How do you clean a field that's supposed to be a date or a number, for
> example, if the user doesn't provide a legal date or number? If you're
> not allowed to throw validation errors during cleaning, you could find
> yourself in a situation where your later cleaning code makes
> assumptions that aren't true. Better to realize that, in the process
> of cleaning, you may discover validation problems that require errors.
>
> Todd

Makes sense! I was probably to narrow-minded on my use case.
So I step back from splitting it up into clean() and validate().

Making available all the cleaned_data inside each clean_<field>()
method is just what is needed!

thx for all the input and help!

Wolfram

>
> On Nov 23, 2007 8:59 AM, Wolfram Kriesing <[EMAIL PROTECTED]> wrote:
> >
> > We discussed this here again, and it looks like newforms currently
> > mixes cleaning and validating data in a not so ideal way.
> >
> > Actually the clean and validation process should be separated, there
> > should be clean-methods and validate-methods. The process should work
> > in the following way, to allow full flexibility:
> >
> > 1) call Field.clean() - to clean the data, NOT throw any errors, just
> > do basic data cleaning if necessary.
> > 2) call Form.clean_<field>() - provide _all_form_ data to this method,
> > so it can also clean the data depending on other form data
> > 3) call Form.clean() - stuff that needs to be done _after_ every
> > single field had been cleaned
> >
> > 4) call Field.validate() - use the cleaned data to validate the fields
> > 5) call Form.validate_<field>()
> > 6) call Form.validate()
> >
> > looks cleaner in my eyes. opinions please!
> >
> > wolfram
> >
> >
> > On Nov 23, 2007 2:45 PM, Wolfram Kriesing <[EMAIL PROTECTED]> wrote:
> > > On Nov 23, 2007 2:41 PM, Matthias Kestenholz <[EMAIL PROTECTED]> wrote:
> > > >
> > > >
> > > > On Fri, 2007-11-23 at 14:30 +0100, Wolfram Kriesing wrote:
> > > > > :-) yep we also discussed that here
> > > > > still it seems "wrong" that it needs to be done with such a hacky way 
> > > > > around
> > > > >
> > > >
> > > > I don't think that's hacky at all, really. If you want an URLField, you
> > > > get a field that guarantees that it really contains an URL. Otherwise it
> > > > should get called fields.MaybeURLField, and what would be the difference
> > > > between that and a plain CharField?
> > > >
> > > > You can even validate the URL in clean_url()
> > > >
> > > > But take whatever works for you...
> > >
> > > sounds right too :-). thx for the help!
> > > but see the other two drawbacks i wrote in the other mail
> > >
> > > wolfram
> > >
> > > >
> > > > --
> > > >
> > > > http://spinlock.ch/blog/
> > > >
> > > >
> > > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > cu
> > >
> > > Wolfram
> > >
> >
> >
> >
> > --
> > cu
> >
> > Wolfram
>
> >
> > >
> >
>
> >
>



-- 
cu

Wolfram

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to