PHP code example of pedrohenriques / data-validator

1. Go to this page and download the library: Download pedrohenriques/data-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/ */

    

pedrohenriques / data-validator example snippets


	namespace DataValidator\Validations;

	use DataValidator\Interfaces\iValidation;

	class ValMyClass implements iValidation {
		public function runCheck($field, $input, array $params) {
			// validation code goes here!
			// return True if the validation passed or False if it failed.
		}
	}
	

	$validator->addValidation("custom_val", function($field, $input, array $params) {
		// validation code goes here!
		// return True if the validation passed or False if it failed.
	});
	

$data = [
	"commission" => "20",
	"tax" => "25"
];

$validations = [
	"commission;Commission Perc." => ["custom_val;10;100;47"],
	"tax;Tax Perc." => ["match;%commission%"]
];

$data = [
	"commission" => "20",
	"tax" => "25"
];

$validations = [
	"commission;Commission Perc." => ["custom_val;10;100;47"],
	"tax;Tax Perc." => ["match;%commission%"]
];

$short_circuit_rules = [
	["check" => "null, ""], "run_check" => false]
];