Comments (7)
In which context do you want to create and execute the chain. I think this could lead to heavy objects, because there are so much dependencies (Hydrator, Validator, Filter, ...).
And in my opinion the code is really hard to read.
But aside of this, it could be a great feature.
from zend-inputfilter.
Chain can be created from static methods and added to input filters
$inputFilter->addInput("input name", Chain $chain);
$result = $inputFilter->resolve($inputValuesArray);
$result->isValid();
$result->getValues();
About the code legibility this is as easy as use local vars or refactor dependent components for be API compatible.
$removeWhitespaces = ...;
$validateIsFormattedAsADate = ...;
$chain
->then($removeWhitespaces)
->then($validateIsFormattedAsADate)
->then(null, $setFallbackValue)
;
About the dependencies, there is no dependencies, just callables.
from zend-inputfilter.
Note this way of make chains could replace or remove ValidatorChain and FilterChain classes
from zend-inputfilter.
while I like the idea of replacing *Chain
classes with pipes of callbacks, I'm not keen on using A+ promises terminology for something that is not async at all. It may be confusing for people not familiar with such concepts, and it feels like mixing apples and oranges.
from zend-inputfilter.
Well, who said this things could not be async in the future or with alternative PHP engines.
from zend-inputfilter.
If that was the actual intention, I'd rather have the input filter wrapped in a promise via a dedicated implementation like reactphp/promise, or introduce a new zend component for that purpose, but then again... why would you do that?
A promise-like interface has many aspects that are not that useful in this particular case, all you want to do is just pass an array through a stack of callbacks... Why not rethink the current Chain class to be more generic and simple instead, and avoid the design overhead of things like a "fake-promise" resolution and rejection?
from zend-inputfilter.
This repository has been closed and moved to laminas/laminas-inputfilter; a new issue has been opened at laminas/laminas-inputfilter#6.
from zend-inputfilter.
Related Issues (20)
- Class Zend\ServiceManager\AbstractPluginManager not found HOT 5
- Avoiding the default NotEmpty::IS_EMPTY validation message. HOT 3
- CollectionInputFilter throws exception on scalar input HOT 3
- ConfigProvider - registration of InputFilterAbstractServiceFactory HOT 1
- Value is required message for optional field HOT 8
- [php 7.2] incompatible prototype HOT 2
- InputFilter::getValues() does not throw like it should HOT 2
- Intended behaviour on nested input filters and empty POST data? HOT 2
- FileInput not compatible with PSR (and Dictatoros) UploadedFile HOT 3
- How use Callback validator when field is conditionally required? HOT 3
- Duplicate error messages for collection input field items HOT 14
- Version 2.8.5 broke backward compatibility for apigility HOT 4
- Null value for inputfilter causes exception HOT 28
- Add support for required flag to input filters HOT 2
- collectionRawValues not populated in setData of CollectionInputFilter HOT 15
- MVC InputFilterPluginManager missing InputFilterAbstractFactory config HOT 15
- Input filter specification and merging HOT 1
- Exception when supplying non-array data to an ArrayInput HOT 2
- Empty validation message for file input when sent array for file input HOT 3
- Fatal error: Class 'Zend\ServiceManager\AbstractPluginManager' not found in D:\XAMPP\htdocs\sn\zend-mail\vendor\zendframework\zend-mail\src\Protocol\SmtpPluginManager.php on line 20 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zend-inputfilter.