PHP code example of mascame / katina
1. Go to this page and download the library: Download mascame/katina 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/ */
mascame / katina example snippets
$data = [
'name' => 'John Doe',
'count' => 123,
];
$validator = new \Mascame\Katina\Validator(['name' => ':string', 'count' => ':int']);
$validator->check($data); // true
$data = [
'name' => 'John Doe',
'count' => 145,
'list' => [
'emptyList' => false,
'nested-list' => [
1, 2, 3
]
],
'books' => [
[
'type' => 'book',
'title' => 'Geography book',
'chapters' => [
'eu' => ['title' => 'Europe', 'interesting' => true],
'as' => ['title' => 'America', 'interesting' => false]
]
],
[
'type' => 'book',
'title' => 'Foreign languages book',
'chapters' => [
'de' => ['title' => 'Deutsch']
]
]
]
];
$
$data = [
'my-birthday' => '1980-01-01'
];
$uiredFields);
// You can add or override rules
\Mascame\Katina\Rules::setRules(['birthdayValidator' => function($value) {
return ($value == '1980-01-01');
}]);
$validator->check($data); // true
\Mascame\Katina\Matcher::matches(['test' => true], ['test' => ':bool']); // true