Re: Allowing validation to pass for partial post values?
Iain Duncan <[email protected]> Fri, 27 Jul 2012 13:17:04 -0700
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <CAN9NcLwdnRGo_aAVFYzfDw6oKVjV7wsJ0AyBM3Gh+ezNvZBU2A@mail.gmail.com> |
--===============3862077120203069334== Content-Type: multipart/alternative; boundary=e89a8fb2067e444ab704c5d56551 --e89a8fb2067e444ab704c5d56551 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Jul 27, 2012 at 1:15 PM, Iain Duncan <[email protected]>wrote: > Hi Chris, I'm not sure if what you're suggesting is what I want. Here's a > clarification, maybe you can tell me. > > The schema for my tests looks like: > > class PersonValidationSchema(ValidationSchema): > """validation schema for resource Person""" > name_first = v.UnicodeString(not_empty=True) > name_last = v.UnicodeString(not_empty=True) > birthdate = IsoDate() > > The names can't be empty, which is correct, because I want errors if we're > sent post values with empty strings for them. But what I need to be able to > do for Dojo is receive and *pass* a post dict that is missing a name_last > key, and get a validated dict also missing a name_last key. When that > happens, the write to the db will update only the fields that have keys in > my post vals, and ignore the others ( not setting them to none or any > default value). > > This should pass: { 'name_last':'Duncan', 'birthdate':'1911-01-01'} This should fail: {'name_last':'Duncan', 'name_first': '', 'birthdate': '1911-01-01' } thanks! --e89a8fb2067e444ab704c5d56551 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jul 27, 2012 at 1:15 PM, Iain Duncan <sp= an dir=3D"ltr"><<a href=3D"mailto:[email protected]" target=3D"_= blank">[email protected]</a>></span> wrote:<br><blockquote class= =3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd= ing-left:1ex"> Hi Chris, I'm not sure if what you're suggesting is what I want. He= re's a clarification, maybe you can tell me.<div><br></div><div>The sch= ema for my tests looks like:</div><div><br></div><div><div>class PersonVali= dationSchema(ValidationSchema):</div> <div>=A0 =A0 """validation schema for resource Person"&= quot;"</div><div>=A0 =A0 name_first =3D v.UnicodeString(not_empty=3DTr= ue)</div><div>=A0 =A0 name_last =3D v.UnicodeString(not_empty=3DTrue)</div>= <div>=A0 =A0 birthdate =3D IsoDate()</div> <div><br></div><div>The names can't be empty, which is correct, because= I want errors if we're sent post values with empty strings for them. B= ut what I need to be able to do for Dojo is receive and *pass* a post dict = that is missing a name_last key, and get a validated dict also missing a na= me_last key. When that happens, the write to the db will update only the fi= elds that have keys in my post vals, and ignore the others ( not setting th= em to none or any default value).</div> <div><br></div></div></blockquote><div><br></div><div>This should pass:</di= v><div>{ 'name_last':'Duncan', 'birthdate':'191= 1-01-01'}</div><div><br></div><div>This should fail:</div><div>{'na= me_last':'Duncan', 'name_first': '', 'birth= date': '1911-01-01' }</div> <div><br></div><div>thanks!</div></div> --e89a8fb2067e444ab704c5d56551-- --===============3862077120203069334== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ --===============3862077120203069334== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ FormEncode-discuss mailing list FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/formencode-discuss --===============3862077120203069334==--