Giter Club home page Giter Club logo

parameterjuicer's People

Contributors

chanmix51 avatar lunika avatar scrutinizer-auto-fixer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

lunika

parameterjuicer's Issues

release 1.0 stable?

The project has been in RC for almost 2 month, would it be ok to release it as stable?

Handle null values using a Juicer

Hi there, it's me again!

I found a weird case to handle : I wanted to use a Juicer on a field and when I wrote tests I tried with a null value and found that it throws a php exception about the clean process.

$validator
  ->addField('foo', true)
    ->addJuicer('foo', (new \Chanmix51\ParameterJuicer\ParameterJuicer)
        ->addField('bar', true)
          ->addValidator('bar', function($v) {
            if ("baz" !== $v) {
              throw new \Chanmix51\ParameterJuicer\ValidationException('error.');
            }
          })
    )
;

$data = [
  'foo' => null,
];

$data = $validator->squash($data);

// PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Chanmix51\ParameterJuicer\ParameterJuicer::clean() must be of the type array, null given in /vendor/chanmix51/parameter-juicer/sources/lib/ParameterJuicer.php:348

I think that this case should be handle, what do you think?

Compare two fields

I didn't find a way to compare two fields. For example if you have an array with a min and max value, it could be useful to check that max is greater than min in its validation.

Did you already though about that case and have any idea?

Prioritization for validators

It could be nice to have a way to throw the ValidationException on the first validation fail encountered, instead of stacking all the validation errors. In this way, I would be able to use the validation as following (following this order):

...
   ->addValidator('scope', 'Validation\isNotBlank')
   ->addValidator('scope', 'Validation\isArray')
   ->addValidator('scope', Validation\belongsTo(['foo', 'bar', 'baz']))
...

use a callable for default value ?

Almost everywhere it is possible to use a callable to clean, validate, etc but not for the default value.

I think it can be a good think to use a callable here to because a default value can take some resources like computing a uuid. Using a callable we will have a "lazy loaded" default value.

What do you think ?

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.