PHP code example of utopia-php / validators
1. Go to this page and download the library: Download utopia-php/validators 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/ */
utopia-php / validators example snippets
use Utopia\Validator\Text;
use Utopia\Validator\Range;
$username = new Text(20, min: 3);
$age = new Range(min: 13, max: 120);
if (! $username->isValid($input['username'])) {
throw new InvalidArgumentException($username->getDescription());
}
if (! $age->isValid($input['age'])) {
throw new InvalidArgumentException($age->getDescription());
}
bash
composer