Re: A validator module for PHP7
| From: | Rowan Collins | Date: | Tue, 05 Sep 2017 12:25:51 +0000 |
| Subject: | Re: A validator module for PHP7 | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100382@lists.php.net to get a copy of this message | ||
On 5 September 2017 12:36:42 BST, Lester Caine <lester@lsces.co.uk> 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]