PHP code example of mhcgolds / harpia

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

    

mhcgolds / harpia example snippets


$harpia = new \Mhcgolds\Harpia\Harpia();
$harpia
    ->addAlphaLowerCase() // Regex: [a-z]
    ->addAlphaUpperCase() // Regex: [A-Z]
    ->addNumeric() // Regex: [0-9]
    ->addSpecialChars(); // Regex: [@#!$&_\.]
    
$validPassword = '@Password123';
$invalidPassword = 'myPassword';

$harpia->check($validPassword);
var_dump($harpia->getResult()); // Prints 'bool(true)'

$harpia->check($invalidPassword);
var_dump($harpia->getResult()); // Prints 'bool(false)'

$harpia = new \Mhcgolds\Harpia\Harpia();
$harpia
    ->addAlphaAll()
    ->addCustomPattern('\d', 2);