All Projects → Albert221 → validation

Albert221 / validation

Licence: MIT license
Developer experience focused validator.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to validation

Validot
Validot is a performance-first, compact library for advanced model validation. Using a simple declarative fluent interface, it efficiently handles classes, structs, nested members, collections, nullables, plus any relation or combination of them. It also supports translations, custom logic extensions with tests, and DI containers.
Stars: ✭ 198 (+1220%)
Mutual labels:  validator
Stringformatter
Simple Text Formetter (Credit Card Number, Phone Number, Serial Number etc.) Can be used in all text inputs according to the format pattern. If desired, large minor character restrictions can be made in the format pattern.
Stars: ✭ 231 (+1440%)
Mutual labels:  validator
cron-validate
A cron-expression validator for TypeScript/JavaScript projects.
Stars: ✭ 40 (+166.67%)
Mutual labels:  validator
Email address
The EmailAddress Gem to work with and validate email addresses.
Stars: ✭ 199 (+1226.67%)
Mutual labels:  validator
Copper
A configuration file validator for Kubernetes.
Stars: ✭ 223 (+1386.67%)
Mutual labels:  validator
rust-phonenumber
Library for parsing, formatting and validating international phone numbers.
Stars: ✭ 99 (+560%)
Mutual labels:  validator
Ajv Keywords
Custom JSON-Schema keywords for Ajv validator
Stars: ✭ 186 (+1140%)
Mutual labels:  validator
djburger
Framework for safe and maintainable web-projects.
Stars: ✭ 75 (+400%)
Mutual labels:  validator
Clamav Validator
Laravel virus validator based on ClamAV anti-virus scanner
Stars: ✭ 224 (+1393.33%)
Mutual labels:  validator
finspec-spec
Multi-protocol, machine-readable specifications for financial services
Stars: ✭ 18 (+20%)
Mutual labels:  validator
Heyui
🎉UI Toolkit for Web, Vue2.0 http://www.heyui.top
Stars: ✭ 2,373 (+15720%)
Mutual labels:  validator
Routinator
An RPKI Validator written in Rust
Stars: ✭ 215 (+1333.33%)
Mutual labels:  validator
guice-validator
Guice javax.validation method validation integration
Stars: ✭ 35 (+133.33%)
Mutual labels:  validator
Xmlschema
XML Schema validator and data conversion library for Python
Stars: ✭ 201 (+1240%)
Mutual labels:  validator
garn-validator
Create validations with ease
Stars: ✭ 42 (+180%)
Mutual labels:  validator
Validation
The power of Respect Validation on Laravel
Stars: ✭ 188 (+1153.33%)
Mutual labels:  validator
another-json-schema
Another JSON Schema validator, simple & flexible & intuitive.
Stars: ✭ 48 (+220%)
Mutual labels:  validator
kontrolio
Simple standalone data validation library inspired by Laravel and Symfony
Stars: ✭ 51 (+240%)
Mutual labels:  validator
gulp-html
Gulp plugin for HTML validation, using the official Nu Html Checker (v.Nu)
Stars: ✭ 70 (+366.67%)
Mutual labels:  validator
ngx-translate-lint
Simple CLI tools for check `ngx-translate` keys
Stars: ✭ 25 (+66.67%)
Mutual labels:  validator

Basic validator

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Installation

Via Composer

composer require albert221/validation ^2.0

Usage

use Albert221\Validation\Validator;
use Albert221\Validation\Rule;

// $data = [...];

$verdicts = Validator::build()
    ->addField('username')
        ->addRule(Rule\Required::class)
        ->addRule(Rule\Length::class, ['min' => 4])
        ->addRule(Rule\PdoUnique::class, ['pdo' => $pdo, 'table' => 'users', 'field' => 'username'])
    ->addField('email')
        ->addRule(Rule\Required::class)
        ->addRule(Rule\Email::class)
        ->addRule(Rule\PdoUnique::class, ['pdo' => $pdo, 'table' => 'users', 'field' => 'email'])
    ->addField('password')
        ->addRule(Rule\Required::class)
        ->addRule(Rule\Length::class)
            ->setOption('min', 6) // You can set options that way, too!
        ->addRule(Rule\Complexity::class, ['alpha' => true, 'num' => true, 'special' => true])
            ->setMessage('Your password is too weak!')
    ->addField('confirm_password')
        ->addRule(Rule\SameAs::class, ['field' => 'password']
    ->validate($data);

if ($verdicts->fails()) {
    // Validation failed
}

// Validation passed

# Other methods

$verdicts->passes(); // Is valid?
$verdicts->forField('username'); // Get all verdicts for specified field.
$verdicts->forField('username')->passes(); // Is specified field valid?
$verdicts->toArray(); // Get all verdicts as an array.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].