For phone and sip address, you could use the IS_MATCH validator with an
appropriate regular expression defined. Or you could create a custom
validator.
Bruno covered your other question.
Anthony
On Tuesday, September 4, 2012 3:09:42 PM UTC-4, Daniel Gonzalez wrote:
>
> Hi,
>
> In my application I have a form with (among other data), the following two
> fields:
>
> - channel: a set with three possible values: "voicemail", "sipaddress"
> or "phone".
> - destination: a string, the meaningf of which depends on the value of
> channel.
>
> I have the problem that I attach a validation rule ("require") to the
> destination field, because the validation rule depends on the value of
> "channel"
>
> What I would like to do is to leave the validation rule of the destination
> empty, and then do a manual validation, depending on the value of "channel".
> The rest of the fields would be validated as usual, with form.process(),
> but the destination would be validated manually.
>
> Something like this:
>
> if form.process().accepted:
> if request.var.channel == 'voicemail': validate requests.var.destination
> as a mail address.
> elif request.var.channel == 'sipaddress' validate
> requests.var.destination
> as a sip address.
> elfi request.var.channel == 'phone' validate requests.var.destination
> as a telephone number
>
>
> I have two questions:
>
> - has web2py suppot for validation of telephone numbers and sip
> addresses?
> - how can I manually apply validation rules, so that I can apply
> complex algorithms as the one described while validating?
>
> Thanks
> Daniel
>
--