Back to Validation

IterableVal

docs/validators/IterableVal.md

3.1.12.0 KB
Original Source
<!-- SPDX-License-Identifier: MIT SPDX-FileCopyrightText: (c) Respect Project Contributors SPDX-FileContributor: Alexandre Gomes Gaigalas <[email protected]> SPDX-FileContributor: Henrique Moody <[email protected]> -->

IterableVal

  • IterableVal()

Validates whether the input is an iterable value, in other words, if you can iterate over it with the foreach language construct.

php
v::iterableVal()->assert([]);
// Validation passes successfully

v::iterableVal()->assert(new ArrayObject());
// Validation passes successfully

v::iterableVal()->assert(new stdClass());
// Validation passes successfully

v::iterableVal()->assert('string');
// → "string" must be iterable

Note

This validator doesn't behave as PHP's is_iterable() function because it considers that you can iterate over any object.

Templates

IterableVal::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must be iterable
inverted{{subject}} must not be iterable

Template placeholders

PlaceholderDescription
subjectThe validated input or the custom validator name (if specified).

Categorization

  • Types

Changelog

VersionDescription
3.0.0Templates changed
3.0.0Renamed from IterableType to IterableVal
1.0.8Renamed from Iterable to IterableType
1.0.0Created as Iterable

See Also