Skip to content

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

PHP Validator

A small, chainable PHP library for validating and transforming input values.

Installation

Install the package with Composer:

composer require einlinuus/php-validator

Quick start

<?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();
}

Documentation

License

PHP Validator is licensed under the GNU General Public License v3.0.

Releases

Used by

Contributors

Languages