{"id":24782068,"url":"https://github.com/stephannv/cpf","last_synced_at":"2025-03-24T05:26:35.914Z","repository":{"id":274720412,"uuid":"923848510","full_name":"stephannv/cpf","owner":"stephannv","description":"CPF number validation and formatting for Crystal","archived":false,"fork":false,"pushed_at":"2025-01-28T23:53:26.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T01:02:48.237Z","etag":null,"topics":["crystal","crystal-lang"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/stephannv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2025-01-28T23:33:03.000Z","updated_at":"2025-01-29T00:22:22.000Z","dependencies_parsed_at":"2025-01-29T01:02:55.372Z","dependency_job_id":"02a9d4d3-809a-4390-a474-2079768c09e4","html_url":"https://github.com/stephannv/cpf","commit_stats":null,"previous_names":["stephannv/cpf"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephannv%2Fcpf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephannv%2Fcpf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephannv%2Fcpf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephannv%2Fcpf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephannv","download_url":"https://codeload.github.com/stephannv/cpf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245214123,"owners_count":20578748,"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":["crystal","crystal-lang"],"created_at":"2025-01-29T11:15:58.398Z","updated_at":"2025-03-24T05:26:35.895Z","avatar_url":"https://github.com/stephannv.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CPF\n\nCPF number validation and formatting for Crystal.\n\nCPF (Cadastro de Pessoa Físical) is the Brazilian individual taxpayer registry.\nIt's an 11-digit number in the format 000.000.000-00, where the last 2 numbers\nare check digits, generated through an arithmetic operation on the first nine\ndigits.\n\n[API Reference](https://crystaldoc.info/github/stephannv/cpf)\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     cpf:\n       github: stephannv/cpf\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n[API Reference](https://crystaldoc.info/github/stephannv/cpf)\n\n```crystal\nrequire \"cpf\"\n\n# With valid formatted value\ncpf = CPF.new(\"640.061.830-97\")\ncpf.value # =\u003e \"640.061.830-97\"\ncpf.formatted # =\u003e \"640.061.830-97\"\ncpf.unformatted # =\u003e \"64006183097\"\n\n# With valid unformatted value\ncpf = CPF.new(\"64006183097\")\ncpf.value # =\u003e \"64006183097\"\ncpf.formatted # =\u003e \"640.061.830-97\"\ncpf.unformatted # =\u003e \"64006183097\"\n```\n\nA `CPF` object is designed to never hold an invalid value, so you can assume\nthat a CPF object will always hold a valid value. If you try to initialize a\nCPF object with an invalid value, it will raise an exception:\n\n```crystal\nCPF.new(\"11111111111\") # =\u003e raises `ArgumentError`\n\nCPF.new(\"111.111.111-11\") # =\u003e raises `ArgumentError`\n```\n\nTo safely initialize a CPF object, use the `.parse` method:\n```crystal\n# With invalid value\nCPF.parse(\"11111111111\") # =\u003e nil\n\n# With valid value\nCPF.parse(\"640.061.830-97\") # =\u003e #\u003cCPF:0x104fe0ae0 @value=\"640.061.830-97\"\u003e\n```\n\nYou can use `CPF::Validator` module to validate a CPF number:\n```crystal\nCPF::Validator.valid?(\"11111111111\") # =\u003e false\n\nCPF::Validator.valid?(\"640.061.830-97\") # =\u003e true\n```\n\n## Development\n\n1. `shards install` to install dependencies\n2. `crystal spec` to run tests\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/stephannv/cpf/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [stephann](https://github.com/stephannv) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephannv%2Fcpf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephannv%2Fcpf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephannv%2Fcpf/lists"}