|
|
Choosing A Webhost: |
HTTP Constraint patch: msg#00002lang.perl.modules.html-widget.general
H::W::C::HTTP invalidates empty fields. This minor change (with a test) will let empty fields pass the HTTP constraint. If the field is required, users should use an All constraint as well. Thanks, -A Index: t/constraint_http.t =================================================================== --- t/constraint_http.t (revision 42) +++ t/constraint_http.t (working copy) @@ -1,4 +1,4 @@ -use Test::More tests => 7; +use Test::More tests => 8; use_ok('HTML::Widget'); @@ -53,3 +53,14 @@ my $f = $w->process($query); is( $f->valid('foo'), 0, "Invalid" ); } + +# Empty should be valid +{ + my $query = HTMLWidget::TestLib->mock_query({ foo => '' }); + + my $f = $w->process($query); + is( "$f", <<EOF, 'XML output is filled out form' ); +<form id="widget" method="post"><fieldset><input class="textfield" id="widget_foo" name="foo" type="text" /></fieldset></form> +EOF +} + Index: lib/HTML/Widget/Constraint/HTTP.pm =================================================================== --- lib/HTML/Widget/Constraint/HTTP.pm (revision 42) +++ lib/HTML/Widget/Constraint/HTTP.pm (working copy) @@ -22,7 +22,7 @@ =cut -sub regex { qr/^s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+$/ } +sub regex { qr/^(s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?$/ } =head1 AUTHOR
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [patch] Minor glitch in 1.07 POD, Ash Berlin |
|---|---|
| Next by Date: | Fwd: [rt.cpan.org #20313] embed() discards top level controls, Carl Franks |
| Previous by Thread: | [patch] Minor glitch in 1.07 POD, A. Pagaltzis |
| Next by Thread: | Fwd: [rt.cpan.org #20313] embed() discards top level controls, Carl Franks |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |