1. Go to this page and download the library: Download macocci7/purephp-validation 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/ */
// Set Translations Root Path (optional)
// - The path must end with '/'.
// - 'lang/' folder must be placed under the path.
Validator::translationsRootPath(__DIR__ . '/');
// Set lang: 'en' as default (optional)
Validator::lang('ja');
use Macocci7\PurephpValidation\Rules\PasswordWrapper as Password;
$validator = Validator::make(
data: [ 'password' => 'pass' ],
rules: [
'password' => [
' and at least one lowercase letter
->mixedCase()
// at least one number
->numbers()
// at least one symbol
->symbols()
// not in a data leak
->uncompromised(),
],
],
);
use Illuminate\Validation\Rule;
use Macocci7\PurephpValidation\Rules\FileWrapper as File;
use Symfony\Component\HttpFoundation\File\File as SymfonyFile;
$path = __DIR__ . '/../storage/uploaded/foo.jpg';
$validator = Validator::make(
data: [
'photo' => new SymfonyFile($path),
],
rules: [
'photo' => [
'