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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to