Laminas Validator 2.14.0 issue with strict and strings

Hi,
There has been a recent update to laminas-validator in_array which is now failing to validate strings.

If strict is set to false, the validator works fine, but if it is set to true, it doesn’t work in version 2.14.0, the previous version works as expected.

I am using PHP 7.3
Is there a bug in the validator?

I am using api-tools and I have the following code in the module config that was created with the UI:

   4 => [
                'required' => true,
                'validators' => [
                    0 => [
                        'name' => \Laminas\Validator\InArray::class,
                        'options' => [
                            'haystack' => [
                                0 => 'Y',
                                1 => 'N',
                            ],
                            'strict' => true,
                        ],
                    ],
                ],

For the correct result the constants must be used!

This is the expected behaviour:

$validator = new Laminas\Validator\InArray([
    'haystack' => [
        0 => 'Y',
        1 => 'N',
    ],
    'strict'   => Laminas\Validator\InArray::COMPARE_STRICT,
]);

var_dump($validator->isValid('Y')); // true
var_dump($validator->isValid('N')); // true
var_dump($validator->isValid('X')); // false

$validator = new Laminas\Validator\InArray([
    'haystack' => [
        0 => 'Y',
        1 => 'N',
    ],
    'strict'   => Laminas\Validator\InArray::COMPARE_NOT_STRICT,
]);

var_dump($validator->isValid('Y')); // true
var_dump($validator->isValid('N')); // true
var_dump($validator->isValid('X')); // false

There is a change for PHP 8.0 but it does not related to 7.3:

But I think there is a bug because the current result with non strict comparison is:

$validator = new Laminas\Validator\InArray([
    'haystack' => [
        0 => 'Y',
        1 => 'N',
    ],
    'strict'   => Laminas\Validator\InArray::COMPARE_NOT_STRICT,
]);

var_dump($validator->isValid('Y')); // true
var_dump($validator->isValid('N')); // true
var_dump($validator->isValid('X')); // true

Hi, thanks for your quick response.
What about this, see how if given ‘X’ as a value while strict => true, it gives the wrong answer?

$validator = new Laminas\Validator\InArray([
    'haystack' => [
        0 => 'Y',
        1 => 'N',
    ],
    'strict'   => true,
]);

var_dump($validator->isValid('Y')); // true
var_dump($validator->isValid('N')); // true
var_dump($validator->isValid('X')); // true

$validator = new Laminas\Validator\InArray([
    'haystack' => [
        0 => 'Y',
        1 => 'N',
    ],
    'strict'   => false,
]);

var_dump($validator->isValid('Y')); // true
var_dump($validator->isValid('N')); // true
var_dump($validator->isValid('X')); // false

My previous example was wrong. I will update it later and give you feedback.

Sorry for the delay. I updated my previous example with the current results.

Can you open an issue report on GitHub? Thanks in advance! :+1:

Ticket raised: https://github.com/laminas/laminas-validator/issues/81

Thanks for the help and confirming my suspicions about the library

Resolved here: Laminas Validator 2.14.0 issue with strict and strings · Issue #81 · laminas/laminas-validator · GitHub
Thank you @froschdesign