Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95787 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16743 invoked from network); 8 Sep 2016 11:08:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Sep 2016 11:08:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.214 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.214 mail4-2.serversure.net Linux 2.6 Received: from [217.147.176.214] ([217.147.176.214:43031] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/57-36123-1A641D75 for ; Thu, 08 Sep 2016 07:08:19 -0400 Received: (qmail 10623 invoked by uid 89); 8 Sep 2016 11:08:13 -0000 Received: by simscan 1.3.1 ppid: 10617, pid: 10620, t: 0.0716s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.7?) (lester@rainbowdigitalmedia.org.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 8 Sep 2016 11:08:12 -0000 To: internals@lists.php.net References: <232F1604-2211-4351-B830-EDC958A25D6D@strojny.net> <2de35db0-9974-cc96-83dd-3d2dbd48f7f8@lsces.co.uk> <5b72e9da-068a-bc79-82c2-f36f723f42bb@gmail.com> Message-ID: Date: Thu, 8 Sep 2016 12:08:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][VOTE] Add validation functions to filter module From: lester@lsces.co.uk (Lester Caine) On 08/09/16 10:02, Rowan Collins wrote: > No, I'm suggesting something like: > > if ( > ! validate_int($var, $min, $max) > || ! validate_bool($var, $allowed_bool_types) > || ! validate_string($var, $min_len, $max_len) > || ! validate_string_encoding($var, $encoding) > || ! validate_string_chars($var, $allowed_chars) > || ! validate_string_regex($var, $regex) > || ! validate_string_degit($var, $min_len, $max_len) > || ! $callback($var) // Note: no need to wrap this callback, it's > just a boolean-returning function And I am looking for some way of packaging that into something I can read and write dynamically for each $var ... $var->set_validation_rules($rules); And $rules is going to be an array of items which can then be used for related parallel activities such as populating the browser validation. So the above script is replaced by $var->is_valid(); or if you prefer it throws an exception when you try and set the variable with an invalid input ( or one that does not match a 'strict' rule ). -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk