[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] Re: Q: How to construct a constraint to test/limit the length of an input field...


On 2004-12-22, Kleindenst, Fred <suppressed> wrote:
> Hello CGI::App list,
>
> I'm sure that most of us use C::A::ValidateRM in our apps.  I've written some specific constraints for my projects, and I use them like in this snippet:
>
>                 constraints => {
>                                 dn_id                   => 'OK_int',
>                                 b_qdn                   => 'OK_chars',
>                                 rm                      => 'OK_chars',
>                                 admin_contact_fk        =>
>                                   { constraint  =>  'contact_b_qdn',
>                                     params      => [ qw/ admin_contact_fk b_qdn / ],
>                                   },
>
> 					... etc...
>
> I'm wondering what technique you use to validate the length of input fields?  I've been relying on my javascript/HTML tier (and DB error catching ) up to this point.  My first thought was to write a custom constraint that took a length argument.

It's cheesy, but you can a regular expression to do this:

   b_qdn                   => qr/^.{5}$/, # must be exactly 5 characters.

I think it's because that this easy and works well enough that I haven't
tried harder for any other solution.  

If you are interested in possible updates for better length support in
DFV, let's take the thread over to the DFV list. 

    Mark

-- 
http://mark.stosberg.com/ 


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.