Back to Validation

Countable

docs/validators/Countable.md

3.1.11.5 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]> SPDX-FileContributor: João Torquato <[email protected]> -->

Countable

  • Countable()

Validates if the input is countable, in other words, if you're allowed to use count() function on it.

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

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

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

Templates

Countable::TEMPLATE_STANDARD

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

Template placeholders

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

Categorization

  • Types

Changelog

VersionDescription
3.0.0Templates changed
1.0.0Created from ArrayVal

See Also