PHP code example of azi / validator

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

    

azi / validator example snippets




use azi\Validator;
$v = new Validator();

  $rules = array(
        'name' => 'alpha|

$v->validate( $_POST, $rules );

if ( !$v->passed() ) {
        $v->goBackWithErrors();
    }

  Validator::error('confirm_password', '<span class="error">:message</span>');

$v->registerExpression( 'cnic', '#^([0-9]{13})$#', 'Invalid CNIC number' );
 
Validator::registerExpression($expressionID , $pattern, $message)

 $rules['full_name'] = "

$validator = new azi\validator();
$validator->addRule('isUnique', function($field, $value){
    $query = mysqli_query("SELECT * FROM users WHERE username = $value");
    if($query->affected_rows > 0) {
        return "Username '$value' already exists please try something else";
    }
    
    return true;
);


$validator->validate(
    $_POST, ['username' => 'isUnique|

 $rules['age'] = 'if:gender[Male](

  $rules['password'] = 'ord'] = 'same:password';