> I need to validate a phone number using the PhoneNumber() validator
> and I also need it to make certain that the phone number field is not
> empty.  I am trying to create a compound validator like the following:
>
>     class PhoneValidator(Schema):
>         phone = PhoneNumber() and NotEmpty()
>
> This gives the following message when a number is entered into the
> Phone Number field:
>
>     The input must be dict-like (not a <type 'unicode'>:
> u'123-456-7890')
>
> If the Phone Number field is empty then the following message is
> generated:
>
>     phone: Missing value
>
> Can someone help me with this?


First, PhoneNumber is deprecated and you should use
formencode.national.USPhoneNumber or
formencode.national.InternationalPhoneNumber.

Second, forcing a validator to only accept non-empty values is done via

myvalidator_instance = myvalidator( not_empty=True )

HTH,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown

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

Reply via email to