PHP code example of pravaler / validator

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

    

pravaler / validator example snippets




namespace App\Controller;

use Pravaler\Component\Validator\Validator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class PostController extends Controller
{
    public function savePost(Request $request)
    {
        $data = $request->request->all();
        
        $validator = new Validator([
            'name' => 'ender("post/index.html.twig", [
            'message' => 'The post is valid!'
        ]);
    }
}


$validator = new Validator([
    'field' => 'cpf',
]);

$validator = new Validator([
    'field' => 'email',
]);

$validator = new Validator([
    'field' => 'max:10',
]);

$validator = new Validator([
    'field' => 'min:5',
]);

$validator = new Validator([
    'field' => 'numeric',
]);

// In order for the password confirm to take effect it is necessary to have in the data the password field

$validator = new Validator([
    'field' => 'password_confirm',
]);

$validator = new Validator([
    'field' => '

$validator = new Validator([
    'field' => 'size:1:500',
]);

$validator = new Validator([
    'field' => 'regex:/[1-9]{2}\9\d{8}/',
]);