PHP code example of qdenka / easyvalidation

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

    

qdenka / easyvalidation example snippets


use QDenka\EasyValidation\Application\Validators\ValidatorFactory;

$types = ['email','google_email','disposable_email','url','number','date','ip','uuid','json','base64','phone'];
foreach ($types as $type) {
    $validator = ValidatorFactory::create($type);
    $value = 'test_value_for_' . $type;
    if ($validator && $validator->validate($value)) {
        echo "[$type] valid\n";
    } else {
        echo "[$type] invalid\n";
    }
}

use QDenka\EasyValidation\Infrastructure\Factories\Validator;

if (Validator::isValidEmail('[email protected]')) {
    echo "Valid email";
}

if (Validator::isGoogleMail('[email protected]')) {
    echo "It's a Gmail address";
}

if (Validator::isDisposableEmail('[email protected]')) {
    echo "Disposable email detected";
}

// Other helpers:
Validator::isValidUrl('https://example.com');
Validator::isValidNumber('123.45');
Validator::isValidDate('2023-04-23');
Validator::isValidIp('2001:db8::1');
Validator::isValidUuid('550e8400-e29b-41d4-a716-446655440000');
Validator::isValidJson('{"foo":1}');
Validator::isValidBase64(base64_encode('hello'));  
Validator::isValidPhone('+1234567890');

return [
    'mailinator.com',
    '10minutemail.com',
    // add your domains here
];