Back to Validation

ArrayVal

docs/validators/ArrayVal.md

3.1.12.1 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]> -->

ArrayVal

  • ArrayVal()

Validates if the input is an array or if the input can be used as an array (instance of ArrayAccess or SimpleXMLElement).

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

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

v::arrayVal()->assert(new SimpleXMLElement('<xml></xml>'));
// Validation passes successfully

Templates

ArrayVal::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must be an array
inverted{{subject}} must not be an array

Template placeholders

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

Categorization

  • Arrays
  • Types

Changelog

VersionDescription
3.0.0Templates changed
2.0.0SimpleXMLElement is also considered as valid
1.0.0Renamed from Arr to ArrayVal and validate only if the input can be used as an array (#1)
0.3.9Created as Arr

See Also