Description
This library is originally part of the Claritie framework for validating known as Validator.
Validator alternatives and similar libraries
Based on the "Filtering and Validation" category.
Alternatively, view Validator alternatives based on common mentions on social networks and blogs.
-
ISO-codes
PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Manufacturing Industry, Phone numbers & Zipcodes for many countries -
PHP validate
Lightweight and feature-rich PHP validation and filtering library. Support scene grouping, pre-filtering, array checking, custom validators, custom messages. 轻量且功能丰富的PHP验证、过滤库。支持场景分组,前置过滤,数组检查,自定义验证器,自定义消息。 -
Linio Input
Abstracts HTTP request input handling, providing an easy interface for data hydration and validation -
EU VAT Number Validator
:moneybag: A simple and clean PHP library that validates EU VAT registration numbers against the central ec.europa.eu database (using the official europa API) :eu: -
Cake Validation
[READ-ONLY] Validation library from CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp -
DMS Filter
Library that offers Input Filtering based on Annotations for use with Objects. Check out 2.dev for 2.0 pre-release. -
CSV Blueprint
CSV Validator - Strict and automated line-by-line CSV checking tool based on customizable Yaml schemas -
Distributed locks with Redis and ReactPHP
:lock: Asynchronous distributed locks with Redis and ReactPHP
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Validator or a related project?
README
Validator
This library is originally part of the Claritie framework for validating known as Validator.
Requirements
- PHP >=5.3.6+
Code Examples
$rules = array
(
'name' => 'alpha|required',
'year' => 'num|required',
);
$Validation = new Validator();
$Validation->validate($_POST, $rules);
if (!empty($Validation->getErrors()))
{
print_r($Validation->getErrors());
}
// or more viewable direction:
if (!$Validation->passed())
{
$Validation->goBackWithErrors();
}
- Show validation errors (within HTML)
html <label>Name : <input type="text" name="name"> </label> <?= Validator::error('name') ? Validator::error('name') : ""; ?>
You can wrap error messages with custom HTML markup
Validator::error('confirm_password', '<span class="error">:message</span>');
Rules
- required
- num
- alpha
- alpha-num
- min:[number]
- max:[number]
- same:[field_name]
Custom Expressions & Messages
- Custom Expressions
You can register your custom RegExp before running the validator
$v->registerExpression( 'cnic', '#^([0-9]{13})$#', 'Invalid CNIC number' );
registerExpression method takes 3 arguments
- expressionID - unique name for the expression
- pattern - the RegExp string
- message [optional] - the error message to be retured if the validation fails
Validator::registerExpression($expressionID , $pattern, $message)
- Custom Messages
You can also pass a custom error message with each rule
$rules['full_name'] = "required--Please Enter your name|alpha-- Please don't use special charators and numbers";
Conditional Rules
You can define specific conditional rules for a field
$rules['age'] = 'if:gender[Male](required|min:2|num)';
Comparison Rules
You can also compare a field with another
$rules['password'] = 'required|min:8';
$rules['confirm_password'] = 'same:password';
Installation / Integration:
When using Claritie Beta (Skyfire), you can install Validator by calling 'Validator' within the load::service() function.
load::service('Validator');
Also, externally you can use Validator independently by requiring 'index.php' from the main directory including the rest of the directory folders.
require_once __DIR__.'index.php';
License
Validator is licensed under the MIT License.
Copyright 2015-2019 Travis van der Font
*Note that all licence references and agreements mentioned in the Validator README section above
are relevant to that project's source code only.