On 07/09/17 05:26, Yasuo Ohgaki wrote: > As I wrote in README.md, there are only 3 types of inputs. > > 1. Valid data should accepted. > 2. Valid data should accepted, but user's mistake. e.g. Logical error like > your example above. > 3. Invalid. Anything other than 1 and 2 (i.e. Client cannot send these > value) > > "validate" module is supposed to take care 3 which is nothing to do with > models, etc. > It should validate against input data spec, not logical meaning of the > input. If programmer did this, single responsibility principle is broken.
BUT you require an accurate 'input data spec' in order to establish what is not part of '3' and this is the same metadata that is needed to ALSO define the 'logical checks'. Once you have established that the input data has a valid set of data you need to VALIDATE that the data is within the limits defined by the 'input data spec' and those checks ALSO apply to any subsequent processing of the data set. The 'input data spec' is important not only to your 'single validation process', but also to further processing that data prior to producing some sort of output. ( No mention of databases but in a lot of cases that is where the key metadata resides? ) My point is that the 'input data spec' is not simply a stand alone array of data only used by the validator. It is something either created by other parts of the 'logic' or it is needed to give individual responses to 'user's mistake' as per '2' ... I understand that you want to return a 'fail' at the earliest possible point, and a single step 'validate' meets that need, but the bulk of the reasons validation should fail is because someone is trying to hack a site by creating 'user's mistakes' that pass '3' that are not handled correctly by '2'. I think where the latest offering fails is that it now requires that any 'custom' validation needs to be written in 'C' while that same code may be needed as a PHP version as in Dan's example. The validation processing needs to be ABLE to be iterated through variable by variable once one has established that there IS a valid set of variables to work with. -- 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