cancio-labs/cnpj-validation-function 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cancio-labs/cnpj-validation-function

最新稳定版本:1.0.0

Composer 安装命令:

composer require cancio-labs/cnpj-validation-function

包简介

A function to validate a CNPJ (Brazilian Company ID)

README 文档

README

This tiny package contains some functions to validate a CNPJ (Brazilian Company ID)

Requirements

PHP >= 8.0.0

Installation

composer require cancio-labs/cnpj-validation-function

Functions

  1. is_valid_cnpj
  2. assert_cnpj

How to use it

is_valid_cnpj(string $cnpj): bool

Returns true if the CNPJ is valid, false otherwise.

use function CancioLabs\Cnpj\Functions\is_valid_cnpj;

// Passing formatted CNPJs
is_valid_cnpj('86.338.579/0001-12') // returns true
is_valid_cnpj('46.133.600/0001-01') // returns false

// Passing raw CNPJs
is_valid_cnpj('46133600000129') // returns true
is_valid_cnpj('46133600000101') // returns false

assert_cnpj(string $cnpj): void

Validates the CNPJ and throw an InvalidArgumentException if the CNPJ is not valid.

use function CancioLabs\Cnpj\Functions\assert_cnpj;

// These 2 example will execute normally
assert_cnpj('27.187.233/0001-00');
assert_cnpj('27187233000100');

// These 3 examples throw InvalidArgumentException
assert_cnpj('')
assert_cnpj('foo')
assert_cnpj('27187233000111')

Running Tests

  • From the project root, run: vendor/bin/phpunit .

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2024-08-16