
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@fnando/cpf
Advanced tools
This package does some CPF magic. It allows you to create, validate and format CPF documents.
HINT: Check out the CNPJ counter part available at https://github.com/fnando/cnpj.
This lib is available as a NPM package. To install it, use the following command:
npm install @fnando/cpf --save
If you're using Yarn (and you should):
yarn add @fnando/cpf
// Node.js-specific
const cpf = require("@fnando/cpf/commonjs");
// @import
import * as cpf from "@fnando/cpf"; // import the whole library
import { isValid as isValidCpf } from "@fnando/cpf"; // import just one function
// import via <script>; the lib will available as window.cpf
// <script src="cpf.js"></script>
cpf.isValid("532.820.857-96");
//=> true
cpf.isValid("53282085796");
//=> true
cpf.strip("532.820.857-96");
//=> 53282085796
cpf.format("53282085796");
//=> 532.820.857-96
cpf.generate(true); // generate formatted number
//=> 838.684.734-40
cpf.generate(); // generate unformatted number
//=> 72777632898
On the web, without transformation, just use web/cpf.min.js
.
By default, validations will strip any characters you provide. This means that the following is valid, because only numbers will be considered:
cpf.isValid("101#688!!!!!!542......36");
//=> true
cpf.strip("101#688!!!!!!542......36");
//=> 10168854236
If you want to strict validate strings, use the following signature:
cpf.isValid(number, strict);
The same example would now return false
:
cpf.isValid("101#688!!!!!!542......36", true);
//=> false
FAQs
Validate, generate and format CPF numbers
We found that @fnando/cpf demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.