|
From: Chris L. <ch...@ka...> - 2012-07-27 20:32:40
|
On Fri, Jul 27, 2012 at 4:17 PM, Iain Duncan <iai...@gm...>
>
> This should pass:
> { 'name_last':'Duncan', 'birthdate':'1911-01-01'}
>
> This should fail:
> {'name_last':'Duncan', 'name_first': '', 'birthdate': '1911-01-01' }
>
> thanks!
>
I don't think I am totally clear on the problem yet, but I am guessing that
you don't like the Value Missing error in the first case and the second
case the Empty value error is correct. If that is correct then what you
want I think is:
class PersonValidationSchema(ValidationSchema):
"""validation schema for resource Person"""
# will take if_missing value unvalidated
name_first = v.UnicodeString(not_empty=True, if_missing=None)
name_last = v.UnicodeString(not_empty=True, if_missing=None)
birthdate = IsoDate()
or
class PersonValidationSchema(ValidationSchema):
"""validation schema for resource Person"""
# will totally ignore a missing value (unless if_missing provided)
ignore_key_missing = True
name_first = v.UnicodeString(not_empty=True)
name_last = v.UnicodeString(not_empty=True)
birthdate = IsoDate()
or
class PersonValidationSchema(ValidationSchema):
"""validation schema for resource Person"""
# will run the validator with the value given (i.e. None)
if_key_missing = None
name_first = v.UnicodeString(not_empty=True)
name_last = v.UnicodeString(not_empty=True)
birthdate = IsoDate()
-Chris
--
Christopher Lambacher
ch...@ka...
|