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

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

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

cancio-labs/cpf-validation-function

最新稳定版本:1.0.0

Composer 安装命令:

composer require cancio-labs/cpf-validation-function

包简介

A function to validate a CPF (Brazilian ID)

README 文档

README

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

Requirements

PHP 7.4 or greater is required, nothing else.

Installation

composer require cancio-labs/cpf-validation-function

Functions

  1. is_valid_cpf
  2. assert_cpf

How to use it

is_valid_cpf(string $cpf): bool

Returns true if the CPF is valid, false otherwise.

use function CancioLabs\Functions\Cpf\is_valid_cpf;

// Passing formatted CPFs
is_valid_cpf('170.317.330-90') // returns true
is_valid_cpf('170.317.330-00') // returns false

// Passing raw CPFs
is_valid_cpf('17031733090') // returns true
is_valid_cpf('17031733000') // returns false

assert_cpf(string $cpf): void

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

use function CancioLabs\Functions\Cpf\assert_cpf;

// These 2 example will execute normally
assert_cpf('170.317.330-90');
assert_cpf('17031733090');

// These 3 examples throw InvalidArgumentException
assert_cpf('')
assert_cpf('foo')
assert_cpf('17031733000')

Running Tests

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

统计信息

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

GitHub 信息

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

其他信息

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