perhaps. First send me an example of how it should work in your view
and report errors. Mind that al current validators are designed to
take a string as input.

On Feb 12, 9:51 am, Thadeus Burgess <thade...@thadeusb.com> wrote:
> validators are only for crud / SQLFORM.
>
> If you want to verify the record you must do so manually before insertion.
>
> (value, error) = IS_NOT_EMPTY()(myvalue)
> # value is the same as myvalue, but in the case of validators such as
> IS_UPPER() it is converted to upper case.
> # error is either a blank string for no error, or a string containing
> the error message.
>
> (value, error) = IS_NOT_IN_DB(db, 'mytable.myfield')(myvalue)
>
> So with this you could iterate through the list of values.
>
> for v in db.mytable.myfield.requires:
>     etc etc...
>
> This could be useful if it were included in the new dal...
>
> Would you take a patch to allow db level validation on insert Massimo?
>
> -Thadeus
>
> On Fri, Feb 12, 2010 at 5:36 AM, Christopher Steel
>
> <chris.st...@gmail.com> wrote:
> > It appears that validation only works via forms. I want to insert a
> > value one time but from db.py, what would be the best way to do this.
>
> > I tried this, but the same value gets inserted over and over again...
>
> > db.define_table('mytable',
> >    Field('myfield'))
>
> > db.mytable.myfield.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
> > 'mytable.myfield')]
>
> > record_id = db.mytable.insert(myfield='myvalue')
>
> > Merci!
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to