PHP code example of davebugg / validony

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

    

davebugg / validony example snippets


$validator = (new Validony(
$_POST,                                             // Array to validate 
\DavesValidator\Validator\Messages::$messages,      // Array with error messages
\DavesValidator\Validator\Messages::$filedNames,    // Array to rename fields in answer
\DavesValidator\Validator\Checker::class,           // Class which contains validation methods
['DavesValidator\\Validator\\Validony', 'AnswerErrorCallback'], // Class and static method to send validation error
'en'));// Language for errors (the keys of ...\Messages::$messages or your Class for messages)

//в папке Lists, нужно лишь вернуть массив проверки
$validator->ValidateList(
'TimeValidator', //Method to return the validation rules 
false, // Path to your Lists Directory
'DavesValidator\\Validator\\Lists\\', // Namespace of your classes contains in Lists Folder 
false, // Run Callback functions if found\fields with no valid data
true, // Print field's name in error message
true, // Print field's value in error message
false); // Return all errors in one iteration

$valid = $validator->isValid(); // valid or not
$errors = $validator->getErrors(
false, // return string || array
true); // return array of fields in errors array if true

$init = [ 
    'password' =>  [C::                   // Data
    'password_1' => '42',
    'password2' => '42',
    'password_abcd' => 'abcd'
];
$validatorLists = (new ValidateLists($_POST));
$validatorLists->CheckData($init,false,true,true,true);
$valid = $validatorLists->isValid();
$errors = $validatorLists->getErrors(false, true);