PHP Classes

Quest PHP Validation Library: Validate values with general and custom rules

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 67 All time: 10,326 This week: 89Up
Version License PHP version Categories
quest 1.0.0The PHP License5PHP 5, Validation
Description 

Author

This package can validate values with general and custom rules.

It can take an array of values as a parameter and validate it with a set of rules.

The package supports several types of built-in and custom rules using external classes specified by the applications to implement custom validation logic.

The validation function returns whether all validation rules passed and an array with the list of parameter values that do not give the validation rules.

Currently, it provides classes that implement rules like:

- Blacklisted domains

- Email address

- Minimum number

- Maximum number

- Password

- Required

- Number sequence

Picture of Edward Paul
  Performance   Level  
Name: Edward Paul is available for providing paid consulting. Contact Edward Paul .
Classes: 18 packages by
Country: Nigeria Nigeria
Age: 33
All time rank: 272218 in Nigeria Nigeria
Week rank: 72 Up5 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 10x

Winner: 1x

Example

<?php

require_once 'vendor/autoload.php';

$check = new \App\Checkers\Check([
   
'name' => '',
   
'email' => [
       
'infinitypaul@live.com',
       
'',
       
'ade',
       
'ade@google.com'
   
],
   
'password' => 'eeee'
]);

$check->setRules([
   
'name' => [
       
'required'
   
],
   
'email.*' => [
        new \
App\Checkers\Rules\Required(),
       
'email',
       
'blacklist'
   
],
   
'password' => [
       
'min:5',
       
'sequence'
   
]
]);


if(!
$check->validate()){
   
dump($check->getErrors());
} else {
   
dump("passed");
};





Details

Tech Stack

  • PHP
  • Composer

Download Instruction

  1. Clone the project.
git clone https://github.com/infinitypaul/quest.git projectname

  1. Install dependencies via composer.
composer install 

  1. Run php server.
php -S localhost:8000

  1. Sample Response

img.png

  1. Sample Code
$check = new \App\Checkers\Check([
    'name' => '',
    'email' => [
        'infinitypaul@live.com',
        '',
        'ade',
        'ade@google.com'
    ],
    'password' => 'eeee'
]);

$check->setRules([
    'name' => [
        'required'
    ],
    'email.*' => [
        new \App\Checkers\Rules\Required(),
        'email',
        'blacklist'
    ],
    'password' => [
        'min:5',
        'sequence'
    ]
]);


if(!$check->validate()){
    dump($check->getErrors());
} else {
    dump("passed");
};

You can either define your rules as a class

new \App\Checkers\Rules\Required(),

or as a string

required

you can also define your own rule by extending the Rule Class

class EmailRule extends Rule
{

    /
     * @param $field
     * @param $value
     * @return bool
     */
    public function passes($field, $value): bool
    {
        return filter_var($value, FILTER_VALIDATE_EMAIL);
    }

    /
     * @param $field
     * @return string
     */
    public function message($field): string
    {
        return ucwords($field. ' Must Be A Valid Email Address');
    }
}

If you prefer it to br string base, you can define it in the RuleMap.php

'email' => EmailRule::class

Organization Password Policy

The service is very flexible, and new rules can be added without much code.

What is needed is to create a new rule, extend the RULE class, and define all your conditions and organization password policy like the one below

  • Password/Passphrase Length Policy
  • Password Deny List
  • Password Combination
  • Password Checks to be sure it isn't part of the leaked password

Screenshots  
  • img.png
  Files folder image Files  
File Role Description
Files folder imageapp (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file readMe.md Doc. Documentation

  Files folder image Files  /  app  
File Role Description
Files folder imageCheckers (2 files, 2 directories)

  Files folder image Files  /  app  /  Checkers  
File Role Description
Files folder imageErrors (1 file)
Files folder imageRules (7 files)
  Plain text file Check.php Class Class source
  Plain text file RuleMap.php Class Class source

  Files folder image Files  /  app  /  Checkers  /  Errors  
File Role Description
  Plain text file Errors.php Class Class source

  Files folder image Files  /  app  /  Checkers  /  Rules  
File Role Description
  Plain text file DomainBlackListRule.php Class Class source
  Plain text file EmailRule.php Class Class source
  Plain text file MinRule.php Class Class source
  Plain text file PasswordRule.php Class Class source
  Plain text file Required.php Class Class source
  Plain text file Rule.php Class Class source
  Plain text file Sequence.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:67
This week:0
All time:10,326
This week:89Up