{"id":20424962,"url":"https://github.com/avitex/typed-struct-cast","last_synced_at":"2026-04-18T12:35:05.398Z","repository":{"id":52413894,"uuid":"201161735","full_name":"avitex/typed-struct-cast","owner":"avitex","description":"Casting plugin for TypedStruct","archived":false,"fork":false,"pushed_at":"2021-04-29T21:25:08.000Z","size":16,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T04:44:22.747Z","etag":null,"topics":["elixir-lang","typed-struct"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/avitex.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}},"created_at":"2019-08-08T02:23:05.000Z","updated_at":"2024-09-05T16:47:22.000Z","dependencies_parsed_at":"2022-09-08T15:21:55.153Z","dependency_job_id":null,"html_url":"https://github.com/avitex/typed-struct-cast","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/avitex/typed-struct-cast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitex%2Ftyped-struct-cast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitex%2Ftyped-struct-cast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitex%2Ftyped-struct-cast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitex%2Ftyped-struct-cast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avitex","download_url":"https://codeload.github.com/avitex/typed-struct-cast/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitex%2Ftyped-struct-cast/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31969765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["elixir-lang","typed-struct"],"created_at":"2024-11-15T07:11:37.400Z","updated_at":"2026-04-18T12:35:05.379Z","avatar_url":"https://github.com/avitex.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/avitex/typed-struct-cast.svg?branch=master)](https://travis-ci.com/avitex/typed-struct-cast)\n\n# TypedStruct.Cast\n\n**Casting plugin for [TypedStruct](https://hex.pm/packages/typed_struct)**\n\n## TODO\n\n- Documentation\n- Finish primitive casting\n- Remove requirement on development version of `typed_struct` that supports plugins.\n\n## Installation\n\nAdd `typed_struct_cast` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    # NOTE: Currently not published on hex\n    # {:typed_struct_cast, \"~\u003e 0.1.0\"}\n    {:typed_struct_cast, github: \"avitex/typed-struct-cast\"}\n  ]\nend\n```\n\n## Usage\n\n```elixir\ndefmodule MyCustomType do\n  @behaviour TypedStruct.Cast.Type\n\n  @impl true\n  def cast(_value, _opts) do\n    {:ok, :custom}\n  end\nend\n\ndefmodule MyStruct do\n  use TypedStruct\n  use TypedStruct.Cast # optional\n\n  typedstruct do\n    plugin TypedStruct.Cast.Plugin\n\n    field :foo, integer(), cast: Integer\n    field :bar, MyCustomType.t(), cast: {MyCustomType, [foo: true]}\n  end\nend\n\n# Create a new struct given a map\niex\u003e MyStruct.cast(%{\"foo\" =\u003e \"1\"})\n{:ok, %MyStruct{foo: 1, bar: nil}}\n\n# Create a new struct given a keyword\niex\u003e MyStruct.cast([foo: \"1\", bar: true])\n{:ok, %MyStruct{foo: 1, bar: :custom}}\n\n# Cast params into an existing struct\niex\u003e MyStruct.cast(%MyStruct{bar: :hello}, {\"foo\" =\u003e \"1\"})\n{:ok, %MyStruct{foo: 1, bar: :hello}}\n\n# If you don't `use TypedStruct.Cast`, you can access\n# the same functions like so:\niex\u003e TypedStruct.Cast.cast(MyStruct, %{\"foo\" =\u003e \"1\"})\n{:ok, %MyStruct{foo: 1, bar: nil}}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favitex%2Ftyped-struct-cast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favitex%2Ftyped-struct-cast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favitex%2Ftyped-struct-cast/lists"}