Giter Club home page Giter Club logo

Comments (7)

zf2timo avatar zf2timo commented on August 16, 2024

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.

Maks3w avatar Maks3w commented on August 16, 2024

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.

Maks3w avatar Maks3w commented on August 16, 2024

Note this way of make chains could replace or remove ValidatorChain and FilterChain classes

from zend-inputfilter.

stefanotorresi avatar stefanotorresi commented on August 16, 2024

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.

Maks3w avatar Maks3w commented on August 16, 2024

Well, who said this things could not be async in the future or with alternative PHP engines.

from zend-inputfilter.

stefanotorresi avatar stefanotorresi commented on August 16, 2024

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.

weierophinney avatar weierophinney commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.