{"id":15554152,"url":"https://github.com/fastruby/dotenv_validator","last_synced_at":"2025-04-04T20:05:06.476Z","repository":{"id":39877427,"uuid":"343444642","full_name":"fastruby/dotenv_validator","owner":"fastruby","description":"This gem check if required env variables are present and its format using the .env and .env.sample files from Dotenv.","archived":false,"fork":false,"pushed_at":"2024-10-10T02:39:09.000Z","size":219,"stargazers_count":52,"open_issues_count":1,"forks_count":4,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-28T19:07:36.658Z","etag":null,"topics":["dotenv","env","hacktoberfest","rails","ruby"],"latest_commit_sha":null,"homepage":"https://www.fastruby.io/blog/open-source/introducing-dotenv-validator.html","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/fastruby.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2021-03-01T14:27:34.000Z","updated_at":"2025-03-14T23:24:48.000Z","dependencies_parsed_at":"2024-12-28T11:16:55.512Z","dependency_job_id":null,"html_url":"https://github.com/fastruby/dotenv_validator","commit_stats":{"total_commits":79,"total_committers":12,"mean_commits":6.583333333333333,"dds":"0.49367088607594933","last_synced_commit":"e1cb60256bea507b8231df99690141ff2aedbd12"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fdotenv_validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fdotenv_validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fdotenv_validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fdotenv_validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastruby","download_url":"https://codeload.github.com/fastruby/dotenv_validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242669,"owners_count":20907133,"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":["dotenv","env","hacktoberfest","rails","ruby"],"created_at":"2024-10-02T14:50:07.909Z","updated_at":"2025-04-04T20:05:06.438Z","avatar_url":"https://github.com/fastruby.png","language":"Ruby","readme":"# Dotenv Validator\n\n[![Gem Version](https://badge.fury.io/rb/dotenv_validator.svg)](https://badge.fury.io/rb/dotenv_validator) [![Matrix Testing + Lint](https://github.com/fastruby/dotenv_validator/actions/workflows/main.yml/badge.svg)](https://github.com/fastruby/dotenv_validator/actions/workflows/main.yml) [![codecov](https://codecov.io/gh/fastruby/dotenv_validator/branch/main/graph/badge.svg)](https://codecov.io/gh/fastruby/dotenv_validator) [![Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/gems/dotenv_validator/) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)\n\nThis gem validates `.env` variables. You can configure validation rules by\nadding the appropriate comments to the `.env.sample` or `.env.template` file.\n\n# Installation\n\nAdd the gem to your Gemfile:\n\n```\ngem \"dotenv_validator\"\n```\n\nCall `DotenvValidator.check!` in an initializer:\n\n```\necho \"DotenvValidator.check!\" \u003e \"config/initializers/1_dotenv_validator.rb\"\n```\n\n\u003e Note the `1_` in the name so it's executed before any other initializer, since initializers are run in alphabetical order.\n\n\u003e You can use `DotenvValidator.check` without the `!` to show warnings instead of raising an exception.\n\n## Updating\n\nSimply run:\n\n```\nbundle update dotenv_validator\n```\n\n# Configuring env variable\n\nIn your `.env.sample` or `.env.template` file, you can add comments to tell DotenvValidator how to validate the variable:\n\n```\nMY_REQUIRED_VAR=value #required\nTHIS_IS_AN_OPTIONAL_INT=123 #format=int\nTHIS_IS_A_REQUIRED_EMAIL=123 #required,format=email\n```\n\n## Formats\n\n- `int` or `integer` or `Integer`\n- `float` or `Float` (note that all integers are floats too)\n- `str` or `string` or `String` (accepts anything)\n- `email` (checks value against `/[\\w@]+@[\\w@]+\\.[\\w@]+/`)\n- `url` (checks value against `/https?:\\/\\/.+/`)\n- `bool` or `boolean` or `Boolean` (checks value against `true` or `false`, case sensitive)\n- `uuid` or `UUID` (checks value against `/\\A[\\da-f]{32}\\z/i` or `/\\A[\\da-f]{8}-([\\da-f]{4}-){3}[\\da-f]{12}\\z/i`)\n- any other value acts as a regexp!\n\n### Regexp format\n\nIf you have a complex format, you can use a regexp for validation:\n\n```\nMY_WEIRD_ENV_VAR=123_ABC #required,format=\\d{3}_\\w{3}\n```\n\nIn the above example, `\\d{3}_\\w{3}` is converted to a regexp and the value is checked against it.\n\n## If you use `docker-compose`, read this\n\nDocker Compose automatically reads `.env` files present in the project's root when running `docker-compose up`. What this means is that, if you use `dotenv_validator` in an app you run using Docker Compose, you might get exceptions or warnings about your variables being in the wrong format even though they're right. The reason is that, when running `docker-compose up`, docker-compose parses the `.env` file before the Rails application starts. It reads each line as is with a really simple parser (no quotes, comments and trailing spaces handling).\n\nThen, since `docker-compose` already set the environment variables, the Dotenv gem won't override them. It parses the file as we'd expect, but it won't change env variables that are already set.\n\nFor more information check this [page](https://docs.docker.com/compose/environment-variables/#set-environment-variables-in-containers) from their docs.\n\nThe workaround is to rename your `.env` file when using docker. [Here](https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use) you'll find all naming options acceptable for dotenv and that Docker will not automatically parse.\n\nIf renaming is not an option, then you need to remove any comments or trailing whitespaces from your `.env` file:\n\n```\nSMTP_PORT=25         #format=int\n```\n\nneeds to become:\n\n```\nSMTP_PORT=25\n```\n\n### TL;DR\n\nRename your `.env` file according to this [table](https://github.com/bkeepers/dotenv?tab=readme-ov-file#customizing-rails)\n\nor\n\nRemove all comments and trailing whitespaces\n\n## Contributing\n\nWant to make your first contribution to this project? Get started with some of [our good first issues](https://github.com/fastruby/dotenv_validator/contribute)!\n\nBug reports and pull requests are welcome on GitHub at [https://github.com/fastruby/dotenv_validator](https://github.com/fastruby/dotenv_validator). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\nWhen Submitting a Pull Request:\n\n- If your PR closes any open GitHub issues, please include `Closes #XXXX` in your comment\n\n- Please include a summary of the change and which issue is fixed or which feature is introduced.\n\n- If changes to the behavior are made, clearly describe what changes.\n\n- If changes to the UI are made, please include screenshots of the before and after.\n\n## Sponsorship\n\n![FastRuby.io | Rails Upgrade Services](fastruby-logo.png)\n\n`dotenv_validator` is maintained and funded by [FastRuby.io](https://fastruby.io). The names and logos for FastRuby.io are trademarks of The Lean Software Boutique LLC.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastruby%2Fdotenv_validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastruby%2Fdotenv_validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastruby%2Fdotenv_validator/lists"}