1. Go to this page and download the library: Download franzose/kontrolio 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/ */
franzose / kontrolio example snippets
// In container unaware environments
$valid = Factory::getInstance()->make($data, $rules, $messages)->validate();
// Using a service container implementation
$container->singleton('validation', static fn() => new Factory());
$container->get('validation')->make($data, $rules, $messages)->validate();
$validator = new Validator($data, $rules, $messages)->extend($custom)->validate();
$factory = (new Factory())->extend([CustomRule::class]);
// with a custom identifier
$factory = (new Factory())->extend(['some_custom' => CustomRule::class]);
$validator = $factory->make([], [], []);
// if you don't use factory
$validator = new Validator([], [], []);
$validator->extend([CustomRule::class]);
// with a custom identifier
$validator->extend(['custom' => CustomRule::class]);
$validator->validate();
$rules = [
'one' => 'sometimes|length:5,15',
// 'one' => [
// new Sometimes(),
// new Length(5, 15)
// ]
];
$validator->shouldStopOnFailure()->validate();
$data = [
'attr' => '',
'attr2' => 'value2'
];
$rules = [
'attr' => [
new UntilFirstFailure(),
new NotBlank(),
new NotFooBar()
]
];
$messages = [<...>];
$validator = new Validator($data, $rules, $messages)->validate();
$messages = [
'foo' => 'Foo cannot be null',
'foo.length' => 'Wrong length of foo',
'foo.length.min' => 'Foo is less than 3'
// '[attribute].[rule].[violation]
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.