PHP code example of yandjin / custom-validation

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

    

yandjin / custom-validation example snippets


composer 

use YanDjin\Validation\CustomValidation;

$arrayOfData = [
    "name" => "YanDjin",
    "age" => 26
];

if(!CustomValidation::validateData($arrayOfData, [
    "name" => "characters",
    "age" => "numeric|min:18" // pipe the validation rules (: for parameters ) or use array "age" => ["numeric", "min" => 18]
]) {
    // returns the fields not passing the validation and the errors
    return CustomValidation::getErrorsMessagesAsString();
}