{"id":26477532,"url":"https://github.com/leadcodedev/env_guard","last_synced_at":"2026-04-14T17:31:27.812Z","repository":{"id":280823656,"uuid":"943187151","full_name":"LeadcodeDev/env_guard","owner":"LeadcodeDev","description":"Env Guard is a robust, typed validation library for Dart/Flutter, designed to simplify and secure the management of environment variables in your applications.","archived":false,"fork":false,"pushed_at":"2025-03-08T21:13:50.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T23:34:56.273Z","etag":null,"topics":["dart","environment-variables","flutter"],"latest_commit_sha":null,"homepage":"","language":"Dart","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/LeadcodeDev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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-03-05T09:57:03.000Z","updated_at":"2025-03-08T21:12:54.000Z","dependencies_parsed_at":"2025-03-05T14:43:03.205Z","dependency_job_id":null,"html_url":"https://github.com/LeadcodeDev/env_guard","commit_stats":null,"previous_names":["leadcodedev/env_guard"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Fenv_guard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Fenv_guard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Fenv_guard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Fenv_guard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LeadcodeDev","download_url":"https://codeload.github.com/LeadcodeDev/env_guard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244530998,"owners_count":20467388,"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":["dart","environment-variables","flutter"],"created_at":"2025-03-20T00:47:33.632Z","updated_at":"2026-04-14T17:31:27.806Z","avatar_url":"https://github.com/LeadcodeDev.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚙️ Env Guard\n\nEnv Guard is a robust, typed validation library for Dart/Flutter, designed to simplify and secure the management of environment variables in your applications. \n\nThe library offers an elegant solution for validating and transforming environment data, ensuring that it complies with an expected format before being used.\n\n![icons technologies](https://skillicons.dev/icons?i=dart,flutter)\n\n## 🛠 Key features\n\n| Feature                  | Description                                                |\n| ------------------------ | ---------------------------------------------------------- |\n| ✅ Type-Safe Validation   | Define schemas with a fluent API and ensure data integrity |\n| 🧱 Rich Set of Validators | Strings, numbers, booleans, enums                          |\n| 🔄 Data Transformation    | Transform values during validation                         |\n| 🚧 Null Safety            | Full support for optional properties                       |\n| 📦 Extremely small size   | Package size `\u003c 8kb`                                       |\n\n\n## ✨ Simply to use\n\nConsider the following example, where we define a schema for our application's environment variables.\n```dotenv\nHOST=127.0.0.1\nPORT=8080\nLOG_LEVEL=debug\nURI={HOST}:{PORT}\n```\n\nWe can validate these environment variables using the `env_guard` library in the following way.\n```dart\nenum LogLevel implements Enumerate\u003cString\u003e{\n  info('info'),\n  error('error'),\n  debug('debug');\n  \n  final String value;\n  const LogLevel(this.value);\n}\n\nvoid main() {\n  env.define({\n    'HOST': env.string(),\n    'PORT': env.number(),\n    'LOG_LEVEL': env.enumerable(LogLevel.values),\n  });\n\n  expect(env.get('HOST'), '127.0.0.1');\n  expect(env.get('URI'), '127.0.0.1:8080');\n}\n```\n\n### 💪 Enforce data recovery\n\nYou can define your validation constraints from an enumeration to make the names of your variables contractual in addition to your types.\n\n```dart\nfinal class Env implements DefineEnvironment {\n  static final String host = 'HOST';\n  static final String port = 'PORT';\n  static final String uri = 'URI';\n\n  @override\n  final Map\u003cString, EnvSchema\u003e schema = {\n    host: env.string().optional(),\n    port: env.number().integer(),\n    uri: env.string(),\n  };\n}\n```\n\n```dart\nvoid main() {\n  env.defineOf(Env.new);\n\n  expect(env.get(Env.host), '127.0.0.1');\n  expect(env.get(Env.port), 8080);\n}\n```\n\n### 🚧 Error handling\nWhen your application starts up and your environment does not meet the requirements defined by the validator, an `EnvGuardException` is thrown using the following format.\n```json\n{\n  \"errors\": [\n    {\n      \"message\": \"The value must be an enum of [info, error, debug]\",\n      \"rule\": \"enum\",\n      \"key\": \"LOG_LEVEL\"\n    }\n  ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleadcodedev%2Fenv_guard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleadcodedev%2Fenv_guard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleadcodedev%2Fenv_guard/lists"}