PHP code example of huenisys / validator

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

    

huenisys / validator example snippets


$dataArr1 = [
    'id' => '1',
    'hash' => 'abc123',
    'title' => 'Some Title'
];

$rulesArr1 = [
    'id' => 'numeric',
    'hash' => 'stringType|alnum',
    'title' => 'stringType|between :10, 20',
];

$this->validator1 = Validator::make(
  $dataArr1,
  $rulesArr1
);

// returns true if passing
$this->validator1->validate();

// returns true if validation fails from above
$this->validator1->fails();

// get errors in markdown
$this->validator1->getErrorsInMd();

// get errors in typical php array bag
$this->validator1->getErrors();