On Jun 10, 8:51 am, Andrei <
and...@zmievski.org> wrote:
> Speaking of optional fields, I was trying to do something like this:
>
> class User(Document):
> structure = {
> 'username' : unicode,
> 'password' : unicode,
> 'reg_time' : int,
> }
> required_fields = ['username', 'password']
> default_values = {'reg_time': timestamp_as_int}
>
> initial = {'username':'foo', 'password':'bar'}
> User(initial).validate()
>
> It threw an exception saying that "reg_time" was missing, but I
> expected the validation to pass because reg_time is an optional
> field.
>
> On Jun 10, 7:40 am, Nicolas Clairon <
clai...@gmail.com> wrote:
>
>
>
> > yep, this should do the trick... We still need an options, like
> > use_floating_fields=True, to specify the new behavior.
>
> > On Thursday, June 10, 2010,Andrei<
and...@zmievski.org> wrote:
> > > I tried to add a comment there, but the commenting/captcha system is
> > > broken.
>
> > > Anyway, why not just omit any field that is not in the requied_fields
> > > list and also does not have a default value? A field like that could
> > > only be inserted with a null value and that's exactly what we want to
> > > prevent.
>
> > > On Jun 10, 6:24 am, Nicolas Clairon <
clai...@gmail.com> wrote:
> > >> Not at this time but this is a great features. I added a case herehttp://
bitbucket.org/namlook/mongokit/issue/67/omitting-optional-fields.
> > >> Feel free to contribute to this proposal.
>
> > >> N.
>