PHP Classes
elePHPant
Icontem

Vourto: Validate request values of different types

Recommend this page to a friend!
  Info   View files Example   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-04-13 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 13 All time: 8,916 This week: 283Up
Version License PHP version Categories
vourto 1.0Custom (specified...5PHP 5, Validation
Description Author

This package can validate request values of different types.

It can take an array of GET or POST request values and validates it according to given types and accepted value formats.

It can check the values maximum and minimum length, matching a pattern, and type.

If all values are valid, a given callback function is called.

  Performance   Level  
Name: Mauro Junior <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: 24
All time rank: 4097337 in Brazil Brazil
Week rank: 1060 Up82 in Brazil Brazil Up

Details

DOCUMENTATION V1.0.0

Vourto is a PHP library that allows agility and usability on the code. The best solution currently.

Installing

You can download the library using Composer (recommended) or simply download it directly from GitHub repository.

Composer

Download the composer file (composer.json) from our repository to you local/public server or copy the below code

{
    "name": "vourto/vourto",
    "description": "PHPLib for code optimization and clean.",
    "type": "library",
    "keywords": ["Vourto", "lib"],
    "license": "MIT",
    "authors": [
        {
            "name": "Mauro Alexandre",
            "email": "profissionalweb04@gmail.com",
            "role": "Development"
        }
    ],
    "require": {
        "php": "^5.6.2 || ^7.0"
    }
}
composer require vourto/vourto

Direct download

Clone the repository

git clone https://github.com/developerdevice/Vourto.git

or download directly

Integrating

To use the library you must include autoload.php in your application

require_once "Vourto/autoload.php";

See below the syntax for better learning

$app = Prop::exec(method [POST | GET], data [array], callback [function]);

NOTE: if isn?t defined the callback returns true case onsuccess event be acioned.

the first example verifies if $_GET['id'] exists and returns a notice error.

require_once "Vourto/autoload.php";

$app = Prop::exec(
	$_GET,
	array("profile" => array(
		"id" => array(
		"callback" => "ID cannot be empty"
		)
	))
);
echo $app->getStd();
$app->close();

//output (onfail)
//ID cannot be empty

//output (onsuccess)
//true

You can use a callback in the event onsuccess

$app = Prop::exec(
	$_GET,
	array("profile" => array(
		"id" => array(
		"callback" => "ID cannot be empty"
		)
	)),
    function(){
        //code here
});

//output (onfail)
//ID cannot be empty

//output (onsuccess)
//[generated the code]

The next examples verifies if id exists and if it's length is < 4 or > 11

require_once "Vourto/autoload.php";

$app = Prop::exec(
	$_GET,
	array("profile" => array(
		"id" => array(
		"minlegth" => array("value" => 4, "callback" => "ID must be at least 4 characters"),
		"maxlegth" => array("value" => 11, "callback" => "ID must be a maximum of 11 characters"),
		"callback" => "ID cannot be empty"
		)
	)),
    function(){
        header("location: page.php?id=${_GET["id"]}");
});
echo $app->getStd();
$app->close();

The code above is equivalent to the below code

if(isset($_GET["id"] === false)){
echo "ID cannot be empty";
}elseif(strlen($_GET["id"]) < 4){
echo "ID must be at least 4 characteres";
}elseif(strlen($_GET["id"]) > 11){
echo "ID must be a maximum of 11 characters";
}else{
header("location: page.php?id=${_GET["id"]}");
}

Now try verifying 2 elements using a lot of if statement's and compare it to using Vourto LIB.

There are yet another functions: - type [numeric, double?] - pattern [regex]

To see more examples: search the path named /bin/ and open the examples files.

Support or Contact

Having trouble with lib ? Contact me and I'll help you sort it out.

  Files folder image Files  
File Role Description
Files folder imageVourto (2 files, 2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file _config.yml Data Auxiliary data

  Files folder image Files  /  Vourto  
File Role Description
Files folder imagebin (5 files)
Files folder imagevendor (1 file, 1 directory)
  Accessible without login Plain text file composer.json Data Auxiliary data
  Accessible without login Plain text file LICENSE.txt Doc. Documentation

  Files folder image Files  /  Vourto  /  bin  
File Role Description
  Accessible without login Plain text file example1.php Example Example script
  Accessible without login Plain text file example2.php Example Example script
  Accessible without login Plain text file example3.php Example Example script
  Accessible without login Plain text file example4.php Example Example script
  Accessible without login Plain text file example5.php Example Example script

  Files folder image Files  /  Vourto  /  vendor  
File Role Description
Files folder image__class (3 files)
  Accessible without login Plain text file autoload.php Example Example script

  Files folder image Files  /  Vourto  /  vendor  /  __class  
File Role Description
  Plain text file Config.class.php Class Class source
  Plain text file Fn.class.php Class Class source
  Plain text file Prop.class.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:13
This week:0
All time:8,916
This week:283Up