I'm in need of a simple URL validator for CForms. It should test whether a string value represents a well-formed URL and if it doesn't, prepend "http://"; and try again.

I think this would nicely cover the use case where you need to specify a website address in a form but don't want to force users to specify the protocol.

Has anybody come up with something similar before?

Also, I would like the field value to be a well-formed URL in any case, so it should always contain a protocol part. Is it allowed for a validator to change the value of its widget? Would it be better instead to define a new "url" datatype and corresponding convertor? It looks cleaner, but it also seems overkill to define a validator, a datatype and a convertor (plus factory classes) just to cover this simple use case.

        WDYT?

                Ugo

--
Ugo Cei
Tech Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Wine & Food Blog: http://www.divinocibo.it/

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to