1. Go to this page and download the library: Download codeedu/code_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/ */
codeedu / code_validator example snippets
public function boot()
{
\Validator::extend('cpf', function ($attibute, $value, $parameters, $validator) {
return (new Cpf())->isValid($value); //Para validar CPF.
});
\Validator::extend('cnpj', function ($attibute, $value, $parameters, $validator) {
return (new Cpf())->isValid($value); //Para validar CNPJ.
});
}
namespace App\Providers;
use Code\Validator\Cpf; // Importando validador Cpf.
use Code\Validator\Cnpjf; // Importando validador Cnpj.
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
// Seu código aqui.
}
public function register()
{
//
}
}
public function store(Request $request)
{
$validatedData = $request->validate([
'title' => 'quired|cnpj', // Validando cnpj
]);
// O post no blog é válido.
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.