Issues

ZF2-337: inArray validator do nothing unless strict is set to true

Issue Type: Bug Created: 2012-06-02T21:25:42.000+0000 Last Updated: 2012-07-12T12:31:04.000+0000 Status: Resolved Fix version(s): Reporter: Michael Ben-Nes (mbn_18) Assignee: Maks 3w (maks3w) Tags: - Zend\Validator

  • validator

Related issues: Attachments:

Description

Unless 'strict' is set to true, the validator just pass the test no matter which data is posted.

Works

<pre class="highlight">
$this->add($factory->createInput(array(
    'name'       => 'activity_type',
    'required'   => true,
    'validators' => array(
        array(
            'name' => 'InArray',
            'options' => array(
                'haystack' => array('test', 0, 'A'),
                'strict'   => true,
            ),
        ),
    ),
)));

Dont works

<pre class="highlight">
$this->add($factory->createInput(array(
    'name'       => 'activity_type',
    'required'   => true,
    'validators' => array(
        array(
            'name' => 'InArray',
            'options' => array(
                'haystack' => array('test', 0, 'A'),
            ),
        ),
    ),
)));

Comments

Posted by Maks 3w (maks3w) on 2012-06-25T08:28:56.000+0000

What data are you using?

Posted by Michael Ben-Nes (mbn_18) on 2012-06-25T09:57:34.000+0000

Simple form post

Posted by Maks 3w (maks3w) on 2012-07-12T11:15:11.000+0000

http://php.net/manual/function.in-array.php#104501

Posted by Maks 3w (maks3w) on 2012-07-12T12:30:35.000+0000

Added a check forcing to use strict mode when 0 is present in the haystack

https://github.com/zendframework/zf2/pull/1858

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts