{"id":15502027,"url":"https://github.com/prodis/wannabe_bool_elixir","last_synced_at":"2025-06-26T10:33:28.677Z","repository":{"id":33725051,"uuid":"161028591","full_name":"prodis/wannabe_bool_elixir","owner":"prodis","description":"If Atom, BitString, Integer and Float values wanna be a boolean value, they can using to_boolean/1 function. ","archived":false,"fork":false,"pushed_at":"2021-11-04T11:37:29.000Z","size":37,"stargazers_count":6,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-17T11:50:07.362Z","etag":null,"topics":["boolean","conversion","elixir","elixir-lang","prodis","wannabe-bool"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prodis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-09T10:37:45.000Z","updated_at":"2025-04-21T11:56:25.000Z","dependencies_parsed_at":"2022-08-07T23:00:35.766Z","dependency_job_id":null,"html_url":"https://github.com/prodis/wannabe_bool_elixir","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/prodis/wannabe_bool_elixir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prodis%2Fwannabe_bool_elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prodis%2Fwannabe_bool_elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prodis%2Fwannabe_bool_elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prodis%2Fwannabe_bool_elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prodis","download_url":"https://codeload.github.com/prodis/wannabe_bool_elixir/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prodis%2Fwannabe_bool_elixir/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262048498,"owners_count":23250568,"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":["boolean","conversion","elixir","elixir-lang","prodis","wannabe-bool"],"created_at":"2024-10-02T09:07:11.245Z","updated_at":"2025-06-26T10:33:28.638Z","avatar_url":"https://github.com/prodis.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wannabe Bool\n\n[![Hex.pm](https://img.shields.io/hexpm/v/wannabe_bool.svg)](https://hex.pm/packages/wannabe_bool)\n[![Docs](https://img.shields.io/badge/hex-docs-542581.svg)](https://hexdocs.pm/wannabe_bool)\n[![Build Status](https://travis-ci.org/prodis/wannabe_bool_elixir.svg?branch=master)](https://travis-ci.org/prodis/wannabe_bool_elixir)\n[![Coverage Status](https://coveralls.io/repos/github/prodis/wannabe_bool_elixir/badge.svg?branch=master)](https://coveralls.io/github/prodis/wannabe_bool_elixir?branch=master)\n[![License](https://img.shields.io/hexpm/l/wannabe_bool.svg)](https://github.com/prodis/wannabe_bool_elixir/blob/master/LICENSE)\n\nIf `Atom`, `String` (`BitString`), `Integer` and `Float` values wanna be a boolean value, they can using `to_boolean/1` function.\n\n## Installation\n\nThe package can be installed by adding `wannabe_bool` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:wannabe_bool, \"~\u003e 0.1.3\"}\n  ]\nend\n```\n\n## Usage\n\nThe `is_boolean/1` function is implemented for `Atom`, `BitString`, `Integer` and `Float` types.\n\nYou can use `is_boolean/1` function importing `WannabeBool` protocol:\n```elixir\niex\u003e import WannabeBool\niex\u003e\niex\u003e to_boolean(\"true\")\ntrue\n```\n\nOr calling it in `WannabeBool` protocol directly:\n```elixir\niex\u003e WannabeBool.to_boolean(\"true\")\ntrue\n```\n\n## Truthy values\n\nEach type has its own \"truthy values\".\n\n### BitString (String)\n\nReturns `true` if the given string is one of these values: `\"t\"`, `\"true\"`, `\"on\"`, `\"y\"`, `\"yes\"`, `\"1\"`.\n\nOtherwise, returns `false`.\n\nTrailling spaces and letter cases are ignored.\n\n#### Examples\n\n```elixir\niex\u003e to_boolean(\"t\")\ntrue\niex\u003e to_boolean(\"T\")\ntrue\niex\u003e to_boolean(\"true\")\ntrue\niex\u003e to_boolean(\"TRUE\")\ntrue\niex\u003e to_boolean(\"on\")\ntrue\niex\u003e to_boolean(\"ON\")\ntrue\niex\u003e to_boolean(\"y\")\ntrue\niex\u003e to_boolean(\"yes\")\ntrue\niex\u003e to_boolean(\"YES\")\ntrue\niex\u003e to_boolean(\"1\")\ntrue\niex\u003e to_boolean(\" t \")\ntrue\niex\u003e to_boolean(\" T \")\ntrue\niex\u003e to_boolean(\" true \")\ntrue\niex\u003e to_boolean(\" TRUE \")\ntrue\niex\u003e to_boolean(\" on \")\ntrue\niex\u003e to_boolean(\" ON \")\ntrue\niex\u003e to_boolean(\" y \")\ntrue\niex\u003e to_boolean(\"Y\")\ntrue\niex\u003e to_boolean(\" Y \")\ntrue\niex\u003e to_boolean(\" yes \")\ntrue\niex\u003e to_boolean(\" YES \")\ntrue\niex\u003e to_boolean(\" 1 \")\ntrue\n\niex\u003e to_boolean(\"false\")\nfalse\niex\u003e to_boolean(\"whatever\")\nfalse\niex\u003e to_boolean(\"\")\nfalse\n```\n\n### Atom\n\nThe same as `my_atom |\u003e to_string() |\u003e to_boolean()`.\n\n`true` and `false` obvisouly returns `true` and `false` respectively. :)\n\n`nil` returns `false`.\n\n#### Examples\n\n```elixir\niex\u003e to_boolean(:\"t\")\ntrue\niex\u003e to_boolean(:\"true\")\ntrue\niex\u003e to_boolean(:\"on\")\ntrue\niex\u003e to_boolean(:\"y\")\ntrue\niex\u003e to_boolean(:\"yes\")\ntrue\niex\u003e to_boolean(:\"1\")\ntrue\n\niex\u003e to_boolean(:\"false\")\nfalse\niex\u003e to_boolean(:\"whatever\")\nfalse\niex\u003e to_boolean(:\"\")\nfalse\n\niex\u003e to_boolean(true)\ntrue\niex\u003e to_boolean(false)\nfalse\niex\u003e to_boolean(nil)\nfalse\n```\n\n### Integer\n\nReturns `false` if the given integer is zero. Otherwise, returns `true`.\n\n#### Examples\n\n```elixir\niex\u003e to_boolean(0)\nfalse\n\niex\u003e to_boolean(1)\ntrue\niex\u003e to_boolean(2)\ntrue\niex\u003e to_boolean(-1)\ntrue\niex\u003e to_boolean(-2)\ntrue\n```\n\n### Float\n\nReturns `false` if the given float is zero. Otherwise, returns `true`.\n\n#### Examples\n\n```elixir\niex\u003e to_boolean(0.0)\nfalse\n\niex\u003e to_boolean(0.1)\ntrue\niex\u003e to_boolean(1.0)\ntrue\niex\u003e to_boolean(-0.1)\ntrue\niex\u003e to_boolean(-1.0)\ntrue\n```\n\n### Other types\n\nFor other not implemented types a `Protocol.UndefinedError` is raised.\n\n#### Example\n\n```elixir\niex\u003e to_boolean([])\n** (Protocol.UndefinedError) protocol WannabeBool not implemented for []. This protocol is implemented for: Atom, BitString, Float, Integer\n```\n\n## Full documentation\n\nThe full documentation is available at [https://hexdocs.pm/wannabe_bool](https://hexdocs.pm/wannabe_bool).\n\n## Contributing\n\nSee the [contributing guide](https://github.com/prodis/wannabe_bool_elixir/blob/master/CONTRIBUTING.md).\n\n## License\n\nWannabe Bool is released under the Apache 2.0 License. See the [LICENSE](https://github.com/prodis/wannabe_bool_elixir/blob/master/LICENSE) file.\n\nCopyright © 2018-2021 Fernando Hamasaki de Amorim\n\n## Author\n\n[Fernando Hamasaki de Amorim (prodis)](https://github.com/prodis)\n\n\u003ca href=\"https://fernandohamasaki.com\" title=\"Prodis' Blog\" target=\"_blank\"\u003e\u003cimg height=\"102\" width=\"151\" src=\"https://raw.githubusercontent.com/prodis/prodis/master/prodis.png\" alt=\"Prodis\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprodis%2Fwannabe_bool_elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprodis%2Fwannabe_bool_elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprodis%2Fwannabe_bool_elixir/lists"}