Search by

einlinuus / php-validator

EinLinuus

Minimal library to validate and transform user input

Package info

github.com/EinLinuus/php-validator

pkg:composer/einlinuus/php-validator

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

1.0.0 2024-02-24 19:22 UTC

This package is auto-updated.

Last update: 2026-09-22 13:34:13 UTC


README

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.