PHP Classes

Wepesi Validation: Validate a set of values using rule classes

Recommend this page to a friend!

  Author Author  
Picture of Boss Ibrahim Mussa
Name: Boss Ibrahim Mussa <contact>
Classes: 11 packages by
Country: Congo Congo
Innovation award
Innovation award
Nominee: 4x


  Detailed description   Download Download .zip .tar.gz  
This package can validate a set of values using rule classes.

It can take an associative array with keys set to field names and values assigned to validation objects.

The validation objects can be defined using calls to validation class functions that implement different validation rules.

Currently, the package implements several types of validation rules:

- Non-empty value

- Minimum and a maximum number value

- Positive or negative number

- Email address

- Etc.

Details

wepesi_validation

this module will help to do your own input validation from http request POST or GET.

INTEGRATION

The integration is the simple thing to do. First you need to define the rule of the input data, and easy way to do so is by using a schema model which help hundle all of the process, then create an instance of Validate which will help validate data input according to rules already defined. While have the instance of validation, you can access check method, with take two parameters, the source and rules;

    $valid = new \Wepesi\App\Validate();
    $schema = new \Wepesi\App\Schema();
    $source = [];
    $rules = ["name" => $schema->string()->min(3)->max(5)->generate()];    
    $valid->check($source,$rules);
  • `source` 
    The `source` is array object of information to be checked.
    $source=[
        "name"=>"wepesi",
        "email"=>"infos@wepesi.cd",
        "link"=>"https://github.com/bim-g/wepesi_validation/",
        "age"=>1
        ];
    
  • `rules` The `rules` contains all the rule for each element of the source to be checked. you start with the name of the index key you want to check, the with the method you want to check. different method are now available according to you need.

    * `Validation Method` now you can validate your keys according to a specify type witch are: - string - number - date, - boolean - file

    // rules 
    $rules=[
        "email"=>$schema->string()->email()->min(9)->max(50)->required()->generate(),    
        "year"=>$schema->number()->email()->min(35)->max(60)->required()->generate()    
    ];

in the example bellow, for the first rule

    "email"=>$schema->string()->email()->min(9)->max(50)->required()->generate()
    
    // check `email` keys should be a:
    // - string: type of the value to be check should be a string
    // - email: that string should be a email
    // - min:9=> the email should have minimum caracters  9 caracter
    // - max:50=> the email should have maximum caracters should exid 50 caracters
    // - required=> it will no be empty

STRING method allow to validation:

- `required`: this to specify that the key will be required means `is not null`.
- `min`: this will check the minimum length of a string,
- `max`: this will check the maximum length of a string,
- `email`: this will check if the value is an email,
- `url`: this will check if the value is url or a link,
- `matches`: this is used tho check if two key has the same value, you should specify the second field to check.

In the example bellow, you can see a complete procured on how to validate data-source

    $source=[
        "name"=>"wepesi",
        "email"=>"infos@wepesi.cd",
        "link"=>"https://github.com/bim-g/wepesi_validation/",
        "age"=>1
        ];
$valid = new \Wepesi\App\Validate();
$schema = new \Wepesi\App\Schema();
    $rules=[
        "name"=>$schema->string()->required()->min(3)->max(30)->generate(),
        "email"=>$schema->string()->required()->min(3)->max(60)->email()->generate(),
        "link"=>$schema->string()->required()->min(3)->max(60)->url()->generate(),
        "age"=>$schema->number()->required()->positive()->generate()
    ];
    
    $valid->check($source,$rules);
    var_dump($valid->passed()); // if everything is correct return true
    var_dump($valid->errors()); // return all errors according to the validation type

  Classes of Boss Ibrahim Mussa  >  Wepesi Validation  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: Wepesi Validation
Base name: wepesi_validation
Description: Validate a set of values using rule classes
Version: -
PHP version: 5
License: The PHP License
 
  Groups   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Validation Validation algorithms View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder image.idea (5 files)
Files folder imageexample (5 files)
Files folder imagesrc (2 files, 5 directories)
Files folder imagetest (1 file, 2 directories)
Accessible without login Plain text file .phpunit-watcher.yml Data Auxiliary data
Accessible without login Plain text file .phpunit.result.cache Data Auxiliary data
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 Aux. Auxiliary script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .idea  
File Role Description
  Accessible without login Plain text file deployment.xml Data Auxiliary data
  Accessible without login Plain text file modules.xml Data Auxiliary data
  Accessible without login Plain text file php.xml Data Auxiliary data
  Accessible without login Plain text file vcs.xml Data Auxiliary data
  Accessible without login Plain text file wepesi_validation.iml Data Auxiliary data

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file boolean.php Example Example script
  Accessible without login Plain text file date.php Example Example script
  Accessible without login Plain text file index.php Aux. Auxiliary script
  Accessible without login Plain text file number.php Example Example script
  Accessible without login Plain text file string.php Example Example script

  Files folder image Files  /  src  
File Role Description
Files folder imageProviders (2 files, 1 directory)
Files folder imageResolver (2 files)
Files folder imageSchema (4 files)
Files folder imageTraits (2 files)
Files folder imageValidator (4 files)
  Plain text file Schema.php Class Class source
  Plain text file Validate.php Class Class source

  Files folder image Files  /  src  /  Providers  
File Role Description
Files folder imageContracts (3 files)
  Plain text file SChemaProvider.php Class Class source
  Plain text file ValidatorProvider.php Class Class source

  Files folder image Files  /  src  /  Providers  /  Contracts  
File Role Description
  Plain text file Contracts.php Class Class source
  Plain text file SchemaContracts.php Class Class source
  Plain text file ValidatorContracts.php Class Class source

  Files folder image Files  /  src  /  Resolver  
File Role Description
  Plain text file Option.php Class Class source
  Plain text file OptionsResolver.php Class Class source

  Files folder image Files  /  src  /  Schema  
File Role Description
  Plain text file BooleanSchema.php Class Class source
  Plain text file DateSchema.php Class Class source
  Plain text file NumberSchema.php Class Class source
  Plain text file StringSchema.php Class Class source

  Files folder image Files  /  src  /  Traits  
File Role Description
  Plain text file ExceptionTraits.php Class Class source
  Plain text file InitTrait.php Class Class source

  Files folder image Files  /  src  /  Validator  
File Role Description
  Plain text file BooleanValidator.php Class Class source
  Plain text file DateValidator.php Class Class source
  Plain text file NumberValidator.php Class Class source
  Plain text file StringValidator.php Class Class source

  Files folder image Files  /  test  
File Role Description
Files folder imageSchema (4 files)
Files folder imageScript (1 file)
  Plain text file SchemaTest.php Class Class source

  Files folder image Files  /  test  /  Schema  
File Role Description
  Plain text file BooleanSchemaTest.php Class Class source
  Plain text file DateSchemaTest.php Class Class source
  Plain text file NumberSchemaTest.php Class Class source
  Plain text file StringSchemaTest.php Class Class source

  Files folder image Files  /  test  /  Script  
File Role Description
  Plain text file StringValidationTest.php Class Class source

Download Download all files: wepesi_validation.tar.gz wepesi_validation.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
File Role Description
Files folder image.idea (5 files)
Files folder imageexample (5 files)
Files folder imagesrc (2 files, 5 directories)
Files folder imagetest (1 file, 2 directories)
Accessible without login Plain text file .phpunit-watcher.yml Data Auxiliary data
Accessible without login Plain text file .phpunit.result.cache Data Auxiliary data
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 Aux. Auxiliary script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .idea  
File Role Description
  Accessible without login Plain text file deployment.xml Data Auxiliary data
  Accessible without login Plain text file modules.xml Data Auxiliary data
  Accessible without login Plain text file php.xml Data Auxiliary data
  Accessible without login Plain text file vcs.xml Data Auxiliary data
  Accessible without login Plain text file wepesi_validation.iml Data Auxiliary data

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file boolean.php Example Example script
  Accessible without login Plain text file date.php Example Example script
  Accessible without login Plain text file index.php Aux. Auxiliary script
  Accessible without login Plain text file number.php Example Example script
  Accessible without login Plain text file string.php Example Example script

  Files folder image Files  /  src  
File Role Description
Files folder imageProviders (2 files, 1 directory)
Files folder imageResolver (2 files)
Files folder imageSchema (4 files)
Files folder imageTraits (2 files)
Files folder imageValidator (4 files)
  Plain text file Schema.php Class Class source
  Plain text file Validate.php Class Class source

  Files folder image Files  /  src  /  Providers  
File Role Description
Files folder imageContracts (3 files)
  Plain text file SChemaProvider.php Class Class source
  Plain text file ValidatorProvider.php Class Class source

  Files folder image Files  /  src  /  Providers  /  Contracts  
File Role Description
  Plain text file Contracts.php Class Class source
  Plain text file SchemaContracts.php Class Class source
  Plain text file ValidatorContracts.php Class Class source

  Files folder image Files  /  src  /  Resolver  
File Role Description
  Plain text file Option.php Class Class source
  Plain text file OptionsResolver.php Class Class source

  Files folder image Files  /  src  /  Schema  
File Role Description
  Plain text file BooleanSchema.php Class Class source
  Plain text file DateSchema.php Class Class source
  Plain text file NumberSchema.php Class Class source
  Plain text file StringSchema.php Class Class source

  Files folder image Files  /  src  /  Traits  
File Role Description
  Plain text file ExceptionTraits.php Class Class source
  Plain text file InitTrait.php Class Class source

  Files folder image Files  /  src  /  Validator  
File Role Description
  Plain text file BooleanValidator.php Class Class source
  Plain text file DateValidator.php Class Class source
  Plain text file NumberValidator.php Class Class source
  Plain text file StringValidator.php Class Class source

  Files folder image Files  /  test  
File Role Description
Files folder imageSchema (4 files)
Files folder imageScript (1 file)
  Plain text file SchemaTest.php Class Class source

  Files folder image Files  /  test  /  Schema  
File Role Description
  Plain text file BooleanSchemaTest.php Class Class source
  Plain text file DateSchemaTest.php Class Class source
  Plain text file NumberSchemaTest.php Class Class source
  Plain text file StringSchemaTest.php Class Class source

  Files folder image Files  /  test  /  Script  
File Role Description
  Plain text file StringValidationTest.php Class Class source

Download Download all files: wepesi_validation.tar.gz wepesi_validation.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.