thiagoprz/cpfcnpj-validator

Laravel package to validate CPF (Brazilian taxpayer identification number) and CNPJ (national registry of legal entities in Brazil)

0.0.6 2022-04-06 17:30 UTC

This package is auto-updated.

Last update: 2024-05-06 22:12:34 UTC


README

A Laravel package to validate CPF and CNPJ requested on the same input.

Tests

CPF

CPF is an individual taxpayer identification number given to people living in Brazil, both native Brazilians and resident foreigners.

CNPJ

CNPJ is the National Registry of Legal Entities in Brazil.

Installation

composer require thiagoprz/cpfcnpj-validator

Usage

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class CnpjController extends Controller
{
    ...
    /**
     * Store action
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            'cnpj_cnpj' => 'required|string|cpfcnpj',
            ...
        ]);
        ...
    }
    ...
}