PHP code example of reptily / api-check
1. Go to this page and download the library: Download reptily/api-check library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
reptily / api-check example snippets
$users = [];
$user = [
'id' => 1,
'name' => 'Bob',
'is_active' => true,
'books' => []
];
$book = [
'id' => 1,
'name' => 'test book',
];
for ($i=0; $i < 100; $i++) {
$user['books'][] = $book;
}
for ($i=0; $i < 500; $i++) {
$users[] = $user;
}
Validator::make($users, [
'*.id' => [' '*.is_active' => [''
ApiCheck::structure([
ApiCheck::TYPE_ARRAYS => [
'id' => ApiCheck::TYPE_INTEGER,
'name' => ApiCheck::TYPE_STRING,
'is_active' => ApiCheck::TYPE_BOOLEAN,
'books' => [
ApiCheck::TYPE_ARRAYS => [
'id' => ApiCheck::TYPE_INTEGER,
'name' => ApiCheck::TYPE_STRING,
]
]
]
], $users);
$result = ApiCheck::checker($response, [
'id' => ApiCheck::TYPE_INTEGER,
'name' => ApiCheck::TYPE_STRING,
]);
$result = ApiCheck::checker($response, [ApiCheck::TYPE_ARRAYS => ApiCheck::TYPE_STRING]);
$result = ApiCheck::checker($response, [
'data' => [
ApiCheck::TYPE_ARRAYS => [
'names' => [
ApiCheck::TYPE_ARRAYS => ApiCheck::TYPE_STRING,
],
],
],
]);