A small, chainable PHP library for validating and transforming input values.
Install the package with Composer:
composer require einlinuus/php-validator<?php
use EinLinuus\PhpValidator\EinLinuus\PhpValidator\Validator;
use EinLinuus\PhpValidator\EinLinuus\PhpValidator\ValidatorException;
require_once __DIR__ . '/vendor/autoload.php';
$validator = new Validator('hello world');
try {
$validator
->isString('Input must be a string')
->isLowercase('Input must be lowercase')
->min(3, 'Input must be at least 3 characters long')
->max(12, 'Input must be at most 12 characters long');
$validated = $validator->get();
} catch (ValidatorException $exception) {
echo 'Invalid: ' . $exception->getMessage();
}- Overview
- Getting started
- Guides
- Reference
- Project documentation
PHP Validator is licensed under the GNU General Public License v3.0.