{"id":15405279,"url":"https://github.com/fnando/cpf_cnpj","last_synced_at":"2025-05-14T19:09:50.887Z","repository":{"id":1764972,"uuid":"5422829","full_name":"fnando/cpf_cnpj","owner":"fnando","description":"🇧🇷 Validate, generate and format CPF/CNPJ numbers. Include command-line tools.","archived":false,"fork":false,"pushed_at":"2024-10-27T20:26:50.000Z","size":73,"stargazers_count":247,"open_issues_count":1,"forks_count":42,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-28T18:45:35.524Z","etag":null,"topics":["cnpj","cpf","gem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"other":["https://paypal.me/nandovieira/🍕"],"github":["fnando"]}},"created_at":"2012-08-15T06:29:38.000Z","updated_at":"2025-04-23T17:44:03.000Z","dependencies_parsed_at":"2024-10-19T11:19:19.191Z","dependency_job_id":"b1d225fa-cfa8-43dd-9ffc-404b36c4c5b4","html_url":"https://github.com/fnando/cpf_cnpj","commit_stats":{"total_commits":46,"total_committers":7,"mean_commits":6.571428571428571,"dds":0.4782608695652174,"last_synced_commit":"6bd324f06e3c0274ed8fb0dc48267334a1879ce4"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fcpf_cnpj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fcpf_cnpj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fcpf_cnpj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fcpf_cnpj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/cpf_cnpj/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251608288,"owners_count":21616849,"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":["cnpj","cpf","gem"],"created_at":"2024-10-01T16:15:52.183Z","updated_at":"2025-05-14T19:09:48.860Z","avatar_url":"https://github.com/fnando.png","language":"Ruby","funding_links":["https://paypal.me/nandovieira/🍕","https://github.com/sponsors/fnando"],"categories":[],"sub_categories":[],"readme":"# CPF/CNPJ\n\n[![Tests](https://github.com/fnando/cpf_cnpj/workflows/ruby-tests/badge.svg)](https://github.com/fnando/cpf_cnpj)\n[![Gem](https://img.shields.io/gem/v/cpf_cnpj.svg)](https://rubygems.org/gems/cpf_cnpj)\n[![Gem](https://img.shields.io/gem/dt/cpf_cnpj.svg)](https://rubygems.org/gems/cpf_cnpj)\n\nThis gem does some\n[CPF](http://en.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas)/[CNPJ](http://en.wikipedia.org/wiki/CNPJ)\nmagic. It allows you to create, validate and format CPF/CNPJ, even through the\ncommand-line.\n\nJust making my life easier when filling these damn numbers on internet bankings\nand government sites.\n\nFor ActiveModel/ActiveRecord validations, please check\n\u003chttps://github.com/fnando/validators\u003e.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem \"cpf_cnpj\"\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install cpf_cnpj\n\n## Usage\n\n### Ruby API\n\nThis library has the same API for both CNPJ/CPF, so only one of them is\ndocumented below.\n\n\u003e [!NOTE]\n\u003e\n\u003e This library already supports the new alphanumeric CNPJ algorithm that will be\n\u003e available starting July 2026. For more information, see\n\u003e \u003chttps://www.gov.br/receitafederal/pt-br/acesso-a-informacao/acoes-e-programas/programas-e-atividades/cnpj-alfanumerico\u003e.\n\n```ruby\nrequire \"cpf_cnpj\"\n\nCPF.format(number)            # Format CPF (xxx.xxx.xxx-xx)\nCPF.valid?(number)            # Check if a CPF is valid\nCPF.generate                  # Generate a random CPF number\nCPF.generate(true)            # Generate a formatted number\n\ncpf = CPF.new(number)\ncpf.formatted                 # Return formatted CPF (xxx.xxx.xxx-xx)\ncpf.stripped                  # Return stripped CPF (xxxxxxxxxxx)\ncpf.valid?                    # Check if CPF is valid\ncpf.number_without_verifier   # Return CPF without verifier digits\n```\n\n#### Strict Validation\n\nBy default, validations will strip any characters that aren't numbers. This\nmeans that `532#####820------857\\n96` is considered a valid number. To perform a\nstrict validation use `strict: true`.\n\n```ruby\nCPF.valid?(number, strict: true)\n```\n\n### Command-line\n\nThis library gives you two binaries: `cpf` and `cnpj`.\n\n    $ cpf --check 532.820.857-96\n    $ $?\n    0\n\n    $ cpf --check 53282085796\n    $ $?\n    0\n\n    $ cpf --format 53282085796\n    532.820.857-96\n\n    $ cpf --strip 532.820.857-96\n    53282085796\n\n    $ cpf --generate\n    417.524.931-17\n\n    $ cpf --generate --strip\n    76001454809\n\n    $ echo 76001454809 | cpf -f\n    760.014.548-09\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am \"Added some feature\"`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fcpf_cnpj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Fcpf_cnpj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fcpf_cnpj/lists"}