PHPackages                             raisins/validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. raisins/validation

ActiveLibrary

raisins/validation
==================

Simple PHP class for Validation

v1.0(6y ago)010MITPHPPHP ^7.2

Since Feb 14Pushed 6y agoCompare

[ Source](https://github.com/rodzyk/Validation)[ Packagist](https://packagist.org/packages/raisins/validation)[ RSS](/packages/raisins-validation/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Simple PHP lib for Validation
=============================

[](#simple-php-lib-for-validation)

Composer Installation
---------------------

[](#composer-installation)

1. Get [Composer](http://getcomposer.org/)
2. Require Raisins Validation with `composer require raisins/validation`
3. Add the following to your application's main PHP file: `require 'vendor/autoload.php';`

Usage
-----

[](#usage)

```
$email = 'example@email.com';
$username = 'admin';
$password = 'test';
$age = 29;

$val = new \Rainsins\Validation();

$val->name('email')->value($email)->pattern('email')->required();
$val->name('username')->value($username)->pattern('alpha')->required();
$val->name('password')->value($password)->customPattern('[A-Za-z0-9-.;_!#@]{5,15}')->required();
$val->name('age')->value($age)->min(18)->max(40);

if(!$val->isSuccess()){
    var_dump($val->getErrors());
}
```

Add errors message in your language
-----------------------------------

[](#add-errors-message-in-your-language)

```
$val = new \Rainsins\Validation();

$this->val->setErrMsg([
    "pattern" => "Поле {name} інвалід.",
    "required" => "Схоже ти забув що поле {name} є обов'язковим."
]);

$val->name('age')->value(23)->min(18)->max(40);

if(!$val->isSuccess()){
    var_dump($val->getErrors());
}
```

### Origilal errors message array

[](#origilal-errors-message-array)

```
$errorMsgs = [
    "pattern" => "Invalid {name} field format",
    "required" => "Field {name} is required.",
    "min" => "{name} field value less than the minimum value",
    "max" => "{name} field value greater than the maximum value",
    "equal" => "Field value {name} does not match",
    "maxSize" => "The {name} file exceeds the maximum size of {filesize} MB.",
    "ext" => "The {name} file is not a {extension}."
];
```

Methods
-------

[](#methods)

MethodParameterDescriptionExamplename$nameReturn field namename('name')value$valueReturn value fieldvalue($\_POST\['name\])file$valueReturn $\_FILES arrayfile($\_FILES\['name'\])pattern$patternReturn an error if the input has a different format than the patternpattern('text')customPattern$patternReturn an error if the input has a different format than the custom patterncustomPattern('\[A-Za-z\]')requiredReturns an error if the input is emptyrequired()min$lengthReturn an error if the input is shorter than the parametermin(10)max$lengthReturn an error if the input is longer than the parametermax(10)equal$valueReturn an error if the input is not same as the parameterequal($value)maxSize$valueReturn an error if the file size exceeds the maximum allowable sizemaxSize(3145728)ext$valueReturn an error if the file extension is not same the parameterext('pdf')isSuccessReturn true if there are no errorsisSuccess()getErrorsReturn an array with validation errorsgetErrors()displayErrorsReturn Html errorsdisplayErrors()resultReturn true if there are no errors or html errorsresult()is\_int$valueReturn true if the value is an integer numberis\_int(1)is\_float$valueReturn true if the value is an float numberis\_float(1.1)is\_alpha$valueReturn true if the value is an alphabetic charactersis\_alpha('test')is\_alphanum$valueReturn true if the value is an alphanumeric charactersis\_alphanum('test1')is\_url$valueReturn true if the value is an url (protocol is required)is\_url('')is\_uri$valueReturn true if the value is an uri (protocol is not required)is\_uri('[www.example.com](http://www.example.com)')is\_bool$valueReturn true if the value is an booleanis\_bool(true)is\_email$valueReturn true if the value is an e-mailis\_email('')Patterns
--------

[](#patterns)

NameDescriptionExampleuriUrl without file extensionfolder-1/folder-2urlUri with file extensionalphaOnly alphabetic charactersWorldwordsAlphabetic characters and spacesHello WorldalphanumAlpha-numeric characterstest2016intInteger number154floatFloat number1,234.56telTelephone number(+39) 081-777-77-77textAlpha-numeric characters, spaces and some special charactersTest1 ,.():;!@&amp;%?fileFile name formatmyfile.pngfolderFolder name formatmy\_foldeaddressAddress formatStreet Name, 99date\_dmyDate in format dd-MM-YYYY01-01-2016date\_ymdDate in format YYYY-MM-dd2016-01-01emailE-Mail format

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2282d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e2fac6a10b6e449a42bcc324956428fc73283805323fe30bb283b5e57c9b4e47?d=identicon)[rodzyk](/maintainers/rodzyk)

---

Top Contributors

[![davidecesarano](https://avatars.githubusercontent.com/u/16277144?v=4)](https://github.com/davidecesarano "davidecesarano (58 commits)")[![rodzyk](https://avatars.githubusercontent.com/u/9738442?v=4)](https://github.com/rodzyk "rodzyk (6 commits)")[![ChrisToxz](https://avatars.githubusercontent.com/u/28065282?v=4)](https://github.com/ChrisToxz "ChrisToxz (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/raisins-validation/health.svg)

```
[![Health](https://phpackages.com/badges/raisins-validation/health.svg)](https://phpackages.com/packages/raisins-validation)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
