Re: [PHP-DEV] A validator module for PHP7

This is only part of a thread. view whole thread
September 5, 2017 12:25 (Rowan Collins)
On 5 September 2017 12:36:42 BST, Lester Caine <> wrote:
>On 05/09/17 12:18, Yasuo Ohgaki wrote: >> I cannot guess people's thought. I appreciated feedback! > >With a decent database layer a lot of the validation you are proposing >is already covered but PDO does not help in this area. Adding another >layer that does not integrate with a storage layer is just adding to >the >current mess ...
Validation should have nothing to do with the storage layer. Or at least, there should be a level of validation separate from the storage layer. Inputs may come from all sorts of sources: the HTTP request, an API, an import file, etc; and they may be going to all sorts of destinations: the HTTP response, a database, an API, an export file, an e-mail, etc. Regardless of where it came from, and where it's going to end up, the application knows what format that input data should be in to use as or populate appropriate domain models. For instance, "age_in_years is a non-negative integer" is an invariant fact about the domain being modelled, even if it's a value that goes nowhere near any form of database. I actually agree that this module doesn't need to replace the existing userland libraries, only to act as a useful base for them, as well as a useful fallback when writing "raw PHP". The key problem is balancing flexibility and usability such that people will reach for this tool rather than brewing their own. Regards, -- Rowan Collins [IMSoP]