Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95046 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51160 invoked from network); 11 Aug 2016 20:19:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2016 20:19:24 -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.230 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.230 mail4-3.serversure.net Linux 2.6 Received: from [217.147.176.230] ([217.147.176.230:42849] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AE/53-25876-BCDDCA75 for ; Thu, 11 Aug 2016 16:19:24 -0400 Received: (qmail 24625 invoked by uid 89); 11 Aug 2016 20:19:20 -0000 Received: by simscan 1.3.1 ppid: 24618, pid: 24621, t: 0.0911s 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; 11 Aug 2016 20:19:20 -0000 To: internals@lists.php.net References: <10fbcb03-5de8-4d9a-da1c-7e2bf77937cb@lsces.co.uk> <5657afc7-7569-5fc4-4a5a-27ed786c4fa5@gmail.com> <0825c173-5cb4-7f65-cf34-b45ca30919a3@lsces.co.uk> <8646c3ad-b929-cb0b-bad4-52a0a7160d16@gmail.com> Message-ID: <11ce571b-964b-5a3e-9f2f-3f69a8bc20b4@lsces.co.uk> Date: Thu, 11 Aug 2016 21:19:20 +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: <8646c3ad-b929-cb0b-bad4-52a0a7160d16@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Simple variable handling. From: lester@lsces.co.uk (Lester Caine) On 11/08/16 16:14, Rowan Collins wrote: > On 11/08/2016 15:49, Lester Caine wrote: >> The question is not how >> you flag an error, but rather when do you check for one. If the 'load' >> function from a database record or the populate from a web form results >> in $age not being valid one handles that situation based on the data >> model. If you are propagating that data after validating has failed then >> the program flow is wrong and adding some exception when you use the >> duff data later does nothing to help? > > Fair enough, so in summary, what you're looking for is a more > comprehensive and/or user-friendly version of the filter_* functions? > > That is, methods to: > - associate validation rules to a variable/array key/object property > - manually check whether the validation rules for one or several > variables currently pass > > But you are not particularly interested in language-level enforcement or > tracking of whether and when these validation rules have been checked, > because you want to insert the validation at specific points in the > workflow. > > Is that an accurate summary? No ... add more than just validation rules. Include facilities such as escape rules, display rules and variable specific material such as error messages. Just how the rules are enforced needs to be flexible and such things as 'required' will vary how the results are interpreted. I don't see that a dynamic scripting language is improved by 'language-level enforcement' when the bulk of the data IS flexible. It is the flexibility to include or exclude checks as required and while a sub-set of code may work better with a fixed set of rules defined at 'design time', just as much code will consist of elements of the data set that will be optional or variable. 'is_valid' on an object with a large set of variables is an equally valid check and if each variable has the autonomy to return it's state depending on other variables, then only the currently 'required' variables need to be set and validated. I AM interested in tracking the state of each variable but the validity of it's state may depend on the specific state of other elements and a failure to set a variable depends on the particular workflow of the whole data set. So creating a workflow that allows different paths based on the results of validation is a lot more flexible than simply calling 'validate' on a static array of variables? But to keep the 'exception' camp happy, there is no reason that the 'strict' mode can't return exceptions while the 'weak' mode allows the error to simply select an alternate path through the code. -- 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