Re: A validator module for PHP7

From: Date: Tue, 05 Sep 2017 11:18:13 +0000
Subject: Re: A validator module for PHP7
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-100379@lists.php.net to get a copy of this message
Hi all, On Tue, Sep 5, 2017 at 12:19 PM, Paul Jones <pmjones88@gmail.com> wrote: > > > On Sep 4, 2017, at 18:06, Marco Pivetta <ocramius@gmail.com> wrote: > > > > On Mon, Sep 4, 2017 at 8:56 PM, Crocodile <crocodile2u@gmail.com> wrote: > > > >> In most cases users would like more than just valid/invalid, i. e. which > >> particular rule(s) failed and also human-readable error messages. As of > >> simple validation that is almost always at hand, filter_* functions do a > >> good job, although I agree that they could be better. I, for one, would > >> like to see a full-featured validation as part of PHP. However, this RFC > >> only looks like a slightly better version of filter_* functions, that > is, > >> the new module will provide almost the same functionality but with a > >> different interface. I would vote against it. > >> > > > > And also, it would need to be better than all of these to be worth > writing > > it in C: > > > > https://packagist.org/search/?q=validator > > And these as well: https://packagist.org/search/?q=filter I cannot guess people's thought. I appreciated feedback! Why do you think basic validation module should be better than full OO implementation(s)? Simple and basic type support NULL/BOOL/INT/FLOAT/STRING/ARRAY/OBJECT is enough for C written PHP module. IMHO, PHP modules are better of to provide basic features that may be extended by user scripts. I picked 1st one on the list as an example. This kind of rule construction is inefficient compare to simple array rules, so I doubt this is the way for basic validator module written by C. $validator = Validation::createValidator(); $violations = $validator->validate('Bernhard', array( new Length(array('min' => 10)), new NotBlank(), )); However, this particular validation class seems it could be good one that wraps validate module for nicer OO API and faster execution. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#100379) next »