Download the PHP package cubicl/php-structure-check without Composer
On this page you can find all versions of the php package cubicl/php-structure-check. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cubicl/php-structure-check
More information about cubicl/php-structure-check
Files in cubicl/php-structure-check
Package php-structure-check
Short Description Structural check of arrays for PHP 7.4+
License MIT
Homepage https://github.com/cubicldev/php-structure-check
Informations about the package php-structure-check
PHP Structure Check
This library can check a complex array structure against a given requirement. The purpose of this library is to create a better experience when testing a result set from an api or something similar.
Installation
Usage
Create a requirement:
Have some sort of external data you want to check.
Check the data against the requirement.
The returned object holds information about the analysis. You can
check the result by calling isValid()
on the result object. To
fetch the errors, simply call getErrors
.
Supported Types
Currently the following types are supported:
- Any
- Nullable
- Bool
- Numeric
- Float
- Int
- String
- Object
- List
- Datetime
- Regex
- Optional
- Enum
There are some open issues with ideas for more types. Feel free to send pull requests.
Additionally you can implement the TypeInterface
and use your own type implementations.
Checks
Checks are special types which can be used to add more rules to a field. So you can check the length of a string, the count of elements in an array or determine if a numeric value is in a given range.
All versions of php-structure-check with dependencies
php Version ^7.4|^8.0