1. Go to this page and download the library: Download anekdotes/validator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// initiate the Validator with inputs and rules
use Anekdotes\Validator;
function doSomething(){
$validator = Validator::make($inputs, $rules);
// test if validator pass all the tests
if($validator->fail()) {
//Log something maybe?
//Display a message maybe?
return false;
}
//Proceed with the data
//Store it in the db?
}
$rules = ["inputField" => "uld validate as a failure
$inputA = ["inputField" => "" ];
$inputB = ["otherInput" => "Whatever" ];
//The following inputs would validate as a success
$inputC = ["inputField" => "Something" ];
$inputD = ["inputField" => "Stuff" , "otherInput" => "anythingElse"];
$rules = ["inputField" => "uld validate as a failure
$inputA = ["inputField" => "" , "otherInput" => "otherInputsValue"];
//The following inputs would validate as a success
$inputB = ["inputField" => "" , "otherInput" => "anythingElse"];
$inputC = ["inputField" => ""];
$inputD = ["inputField" => "Data" , "otherInput" => "otherInputsValue"];
$inputE = ["inputField" => "Data" , "otherInput" => ""];
$rules = ["inputField" => "uld validate as a failure
$inputA = ["inputField" => "" , "otherInput" => "otherInputsValue"];
$inputB = ["inputField" => "" , "otherInput" => "anythingElse"];
//The following inputs would validate as a success
$inputC = ["inputField" => ""];
$inputD = ["inputField" => "Data" , "otherInput" => "otherInputsValue"];
$inputE = ["inputField" => "Data" , "otherInput" => ""];
$rules = ["inputField" => "uld validate as a failure
$inputC = ["inputField" => ""];
//The following inputs would validate as a success
$inputA = ["inputField" => "" , "otherInput" => "otherInputsValue"];
$inputB = ["inputField" => "" , "otherInput" => "anythingElse"];
$inputD = ["inputField" => "Data" , "otherInput" => "otherInputsValue"];
$inputE = ["inputField" => "Data" , "otherInput" => ""];
$rules = ["inputField" => "integer"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "a"];
$inputB = ["inputField" => "12"];
$inputC = ["inputField" => 12.3];
//The following inputs would validate as a success
$inputD = ["inputField" => 1];
$rules = ["inputField" => "numeric"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "a"];
//The following inputs would validate as a success
$inputB = ["inputField" => "12"];
$inputC = ["inputField" => 12.3];
$inputD = ["inputField" => 1];
$rules = ["inputField" => "date"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "a"];
//The following inputs would validate as a success
$inputB = ["inputField" => "1-1-2000"];
$rules = ["inputField" => "different:Git,Hub"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "Git"];
$inputB = ["inputField" => "Hub"];
//The following inputs would validate as a success
$inputC = ["inputField" => "git"];
$inputD = ["inputField" => "toast"];
$inputE = ["inputField" => "GitHub"];
$rules = ["inputField" => "email"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "test"];
$inputB = ["inputField" => "test@test"];
//The following inputs would validate as a success
$inputC = ["inputField" => "[email protected]"];
$inputD = ["inputField" => "[email protected]"];
$rules = ["inputField" => "postalCode"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "test"];
$inputB = ["inputField" => "123456"];
//The following inputs would validate as a success
$inputC = ["inputField" => "J4R 2L6"];
$inputD = ["inputField" => "A1A1A1"];
$rules = ["inputField" => "phoneNumber"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "test"];
$inputB = ["inputField" => "123456"];
//The following inputs would validate as a success
$inputC = ["inputField" => "4507482822"];
$inputD = ["inputField" => "1-800-123-4567"];
$inputE = ["inputField" => "1 (800) 123-4567"];
$rules = ["inputField" => "between:3,5"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "tested"];
$inputB = ["inputField" => 6];
//The following inputs would validate as a success
$inputC = ["inputField" => 4];
$inputD = ["inputField" => "test"];
$inputE = ["inputField" => "5"];
$rules = ["inputField" => "minimum:3"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "ta"];
$inputB = ["inputField" => 2];
//The following inputs would validate as a success
$inputC = ["inputField" => 4];
$inputD = ["inputField" => "est"];
$inputE = ["inputField" => "5"];
$rules = ["inputField" => "maximum:3"];
//The following inputs would validate as a failure
$inputC = ["inputField" => 4];
$inputD = ["inputField" => "test"];
$inputE = ["inputField" => "5"];
//The following inputs would validate as a success
$inputA = ["inputField" => "ta"];
$inputB = ["inputField" => 2];
$rules = ["inputField" => "size:3"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "ta"];
$inputB = ["inputField" => 232];
//The following inputs would validate as a success
$inputC = ["inputField" => 3];
$inputD = ["inputField" => "abs"];
$inputE = ["inputField" => "3"];
$rules = ["inputField" => "length:3"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "ta"];
$inputB = ["inputField" => "3"];
//The following inputs would validate as a success
$inputC = ["inputField" => "125"];
$inputD = ["inputField" => "abs"];
$rules = ["inputField" => "url"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "ta"];
//The following inputs would validate as a success
$inputB = ["inputField" => "http://www.anekdotes.com"];
$inputC = ["inputField" => "www.google.ca"];
$rules = ["inputField" => "validUrl"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "ta"];
//The following inputs would validate as a success
$inputB = ["inputField" => "http://www.anekdotes.com"];
$inputC = ["inputField" => "www.google.ca"];
$rules = ["inputField" => "same:otherInput"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "" , "otherInput" => "otherInputsValue"];
$inputB = ["inputField" => "maybe" , "otherInput" => "anythingElse"];
//The following inputs would validate as a success
$inputC = ["inputField" => "qwerty123456", "otherInput" => "qwerty123456"];
$inputE = ["inputField" => "Data" , "otherInput" => "Data"];
$rules = ["inputField" => "alpha"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "a12b"];
$inputB = ["inputField" => "hi there"];
$inputC = ["inputField" => "marks-the-spot"];
//The following inputs would validate as a success
$inputD = ["inputField" => "anekdotes"];
$rules = ["inputField" => "alpha_num"];
//The following inputs would validate as a failure
$inputB = ["inputField" => "hi there"];
$inputC = ["inputField" => "marks-the-spot"];
//The following inputs would validate as a success
$inputA = ["inputField" => "a12b"];
$inputD = ["inputField" => "anekdotes"];
$rules = ["inputField" => "alpha_num"];
//The following inputs would validate as a failure
$inputB = ["inputField" => "hi there"];
//The following inputs would validate as a success
$inputA = ["inputField" => "a12b"];
$inputC = ["inputField" => "marks-the-spot"];
$inputD = ["inputField" => "anekdotes"];
$rules = ["inputField" => "before:2016-12-31"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "hi there"];
$inputB = ["inputField" => "2017-01-01"];
//The following inputs would validate as a success
$inputC = ["inputField" => "2015-02-28"];
$rules = ["inputField" => "after:2016-12-31"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "hi there"];
$inputC = ["inputField" => "2015-02-28"];
//The following inputs would validate as a success
$inputB = ["inputField" => "2017-01-01"];
$rules = ["inputField" => "digits:4"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "1234567890"];
$inputB = ["inputField" => "1a28"];
//The following inputs would validate as a success
$inputC = ["inputField" => "2017"];
$rules = ["inputField" => "digits_between:4,6"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "1234567890"];
$inputB = ["inputField" => "1a28"];
//The following inputs would validate as a success
$inputC = ["inputField" => "2017"];
$inputD = ["inputField" => "201712"];
$rules = ["inputField" => "confirmed"];
//The following inputs would validate as a failure
$inputA = ["inputField" => "qwerty123" , "inputField_confirmation" => "123456"];
$inputB = ["inputField" => "" , "inputField_confirmation" => "123456"];
$inputC = ["inputField" => "123456"];
//The following inputs would validate as a success
$inputD = ["inputField" => "123456" , "inputField_confirmation" => "123456"];
$inputE = ["inputField" => "[email protected]" , "inputField_confirmation" => "[email protected]"];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.