{"id":15405143,"url":"https://github.com/fnando/cpf","last_synced_at":"2025-04-05T15:07:49.798Z","repository":{"id":31495544,"uuid":"128064337","full_name":"fnando/cpf","owner":"fnando","description":"🇧🇷 Validate, generate and format CPF numbers","archived":false,"fork":false,"pushed_at":"2022-04-03T01:57:18.000Z","size":473,"stargazers_count":166,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T14:12:40.241Z","etag":null,"topics":["cpf","javascript","npm"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnando.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-04T13:14:46.000Z","updated_at":"2024-11-30T05:32:29.000Z","dependencies_parsed_at":"2022-08-07T16:30:21.169Z","dependency_job_id":null,"html_url":"https://github.com/fnando/cpf","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fcpf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fcpf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fcpf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fcpf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/cpf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353746,"owners_count":20925329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpf","javascript","npm"],"created_at":"2024-10-01T16:15:13.476Z","updated_at":"2025-04-05T15:07:49.777Z","avatar_url":"https://github.com/fnando.png","language":"TypeScript","readme":"# CPF\n\n[![Build Status](https://travis-ci.org/fnando/cpf.svg?branch=master)](https://travis-ci.org/fnando/cpf)\n[![NPM package version](https://img.shields.io/npm/v/@fnando/cpf.svg)](https://www.npmjs.com/package/@fnando/cpf)\n![License: MIT](https://img.shields.io/npm/l/@fnando/cpf.svg)\n![Minified size](http://img.badgesize.io/fnando/cpf/master/web/cpf.min.js.svg?label=cpf+min+size)\n![Minified+Gzip size](http://img.badgesize.io/fnando/cpf/master/web/cpf.min.js.svg?compression=gzip\u0026label=cpf+min%2Bgzip+size)\n\nThis package does some\n[CPF](http://en.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas) magic. It\nallows you to create, validate and format CPF documents.\n\n**HINT:** Check out the CNPJ counter part available at\n\u003chttps://github.com/fnando/cnpj\u003e.\n\n## Installation\n\nThis lib is available as a NPM package. To install it, use the following\ncommand:\n\n```\nnpm install @fnando/cpf --save\n```\n\nIf you're using Yarn (and you should):\n\n```\nyarn add @fnando/cpf\n```\n\n## Usage\n\n```js\n// Node.js-specific\nconst cpf = require(\"@fnando/cpf/commonjs\");\n\n// @import\nimport * as cpf from \"@fnando/cpf\"; // import the whole library\nimport { isValid as isValidCpf } from \"@fnando/cpf\"; // import just one function\n\n// import via \u003cscript\u003e; the lib will available as window.CPF\n// \u003cscript src=\"cpf.js\"\u003e\u003c/script\u003e\n\ncpf.isValid(\"532.820.857-96\");\n//=\u003e true\n\ncpf.isValid(\"53282085796\");\n//=\u003e true\n\ncpf.strip(\"532.820.857-96\");\n//=\u003e 53282085796\n\ncpf.format(\"53282085796\");\n//=\u003e 532.820.857-96\n\ncpf.generate(true); // generate formatted number\n//=\u003e 838.684.734-40\n\ncpf.generate(); // generate unformatted number\n//=\u003e 72777632898\n```\n\nOn the web, without transformation, just use `web/cpf.min.js`.\n\n### Strict Validation\n\nBy default, validations will strip any characters you provide. This means that\nthe following is valid, because only numbers will be considered:\n\n```js\ncpf.isValid(\"101#688!!!!!!542......36\");\n//=\u003e true\n\ncpf.strip(\"101#688!!!!!!542......36\");\n//=\u003e 10168854236\n```\n\nIf you want to strict validate strings, use the following signature:\n\n```js\ncpf.isValid(number, strict);\n```\n\nThe same example would now return `false`:\n\n```js\ncpf.isValid(\"101#688!!!!!!542......36\", true);\n//=\u003e false\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fcpf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Fcpf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fcpf/lists"}