{"id":32172400,"url":"https://github.com/nicolkill/map_schema_validator","last_synced_at":"2026-05-01T12:31:15.302Z","repository":{"id":183563097,"uuid":"668935138","full_name":"nicolkill/map_schema_validator","owner":"nicolkill","description":"JSON Schema verifier in Elixir","archived":false,"fork":false,"pushed_at":"2024-01-18T01:11:07.000Z","size":29,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-21T18:43:08.188Z","etag":null,"topics":["elixir","elixir-library","json","json-schema"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicolkill.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-07-21T00:41:37.000Z","updated_at":"2023-07-25T07:49:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"b3cbc3da-0055-4866-8b88-c82f29048d9c","html_url":"https://github.com/nicolkill/map_schema_validator","commit_stats":null,"previous_names":["nicolkill/map_schema_validator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nicolkill/map_schema_validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolkill%2Fmap_schema_validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolkill%2Fmap_schema_validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolkill%2Fmap_schema_validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolkill%2Fmap_schema_validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicolkill","download_url":"https://codeload.github.com/nicolkill/map_schema_validator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolkill%2Fmap_schema_validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32497809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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","elixir-library","json","json-schema"],"created_at":"2025-10-21T18:36:15.332Z","updated_at":"2026-05-01T12:31:15.255Z","avatar_url":"https://github.com/nicolkill.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# map_schema_validator\n\nIt's a map format verifier, verify if keys/values exist in a given map, short and quick, you can specify more than one \nformat and verify list of values.\n\nThe motivation of create this library was verify that a json file content has a specific format and fail in case that \nnot matches raises an error with the route to the invalid field\n\n[Docs here!](https://hexdocs.pm/map_schema_validator)\n\n## Installation\n\nIf [available in Hex](https://hex.pm/packages/map_schema_validator), the package can be installed\nby adding `map_schema_validator` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:map_schema_validator, \"~\u003e 0.1.8\"}\n  ]\nend\n```\n\n## How to use it?\n\nJust use the function [`MapSchemaValidator.validate/2`](https://hexdocs.pm/map_schema_validator/MapSchemaValidator.html#validate/2) \nor [`MapSchemaValidator.validate!/2`](https://hexdocs.pm/map_schema_validator/MapSchemaValidator.html#validate!/2)\n\nAlso, you can use the module [`MapSchemaValidator.Schema`](https://hexdocs.pm/map_schema_validator/MapSchemaValidator.Schema.html)\nto create a schema with all the properties and directly validate the maps without have the schema in other place\n\n## Basic usage\n\nA basic example of the way to use\n\n```elixir\n# MapSchemaValidator\nschema = %{\n  field: %{\n    inner_field: :string\n  }\n}\n\nmap = %{\n  field: %{\n    inner_field: \"value\"\n  }\n}\n\ncase MapSchemaValidator.validate(schema, map) do\n  {:ok, _} -\u003e\n    :ok\n    # your stuff\n  {:error, %MapSchemaValidator.InvalidMapError{message: message}} -\u003e\n    :error\n    # failure\nend\n\ntry do\n  :ok = MapSchemaValidator.validate!(schema, map)\nrescue\n  e in MapSchemaValidator.InvalidMapError -\u003e \n    e.message\nend\n\n# MapSchemaValidator.Schema\n\ndefmodule InnerSchemaModule do\n  use MapSchemaValidator.Schema\n\n  field :inner_field, :string\nend\n\ndefmodule SchemaModule do\n  use MapSchemaValidator.Schema\n\n  field :field, InnerSchemaModule\nend\n\n{:ok, _} = SchemaModule.validate(map)\n```\n\n## Possible values\n\nYou can check inner list of maps or even list of possible values, or even optional values using `?` at the end of the\nfield name in the schema\n\n```\n:float, :integer, :number, :boolean, :string, :datetime, :date, :time, :uuid, [:list], %{type: :map}, [%{type: :map}]\n```\n\n\u003e the list of maps `[%{type: :map}]` are just valid with one object schema, in this case you are validating that an list\n\u003e has the format of the map, but only it's supported one element, multiple object schema options are in backlog\n\n**Primitive types**\n\n```elixir\nschema = %{\n  value_number: :number,\n  value_float: :float,\n  value_integer: :integer,\n  value_boolean: :boolean,\n  value_string: :string,\n  value_datetime: :datetime,\n  value_date: :date,\n  value_time: :time,\n  value_uuid: :uuid\n}\nmap = %{\n  value_number: 1,\n  value_float: 1.1,\n  value_integer: 1,\n  value_boolean: false,\n  value_string: \"value string\",\n  value_datetime: \"2015-01-23 23:50:07\",\n  value_date: \"2015-01-23\",\n  value_time: \"23:50:07\",\n  value_uuid: \"fcfe5f21-8a08-4c9a-9f97-29d2fd6a27b9\"\n}\n\n{:ok, _} = MapSchemaValidator.validate(schema, map)\n```\n\n**Optional keys**\n\n```elixir\nschema = %{\n  mandatory_value: :string,\n  optional_value?: :number\n}\nmap = %{\n  mandatory_value: \"value string\"\n}\n\n{:ok, _} = MapSchemaValidator.validate(schema, map)\n```\n\n\u003e Just adding the `?` char at the end of the key (like Typescript)\n\n**Nested Maps**\n\n```elixir\nschema = %{\n  value_map: %{\n    inner_map: %{\n      inner_value: :string\n    }\n  }\n}\nmap = %{\n  value_map: %{\n    inner_map: %{\n      inner_value: \"value string\"\n    }\n  }\n}\n\n{:ok, _} = MapSchemaValidator.validate(schema, map)\n```\n\n**List of allowed values**\n\n```elixir\nschema = %{\n  value_one_of: [:string, :number],\n}\nmap = %{\n  value_one_of: \"value string\",\n}\n\n{:ok, _} = MapSchemaValidator.validate(schema, map)\n\nmap = %{\n  value_one_of: 100,\n}\n\n{:ok, _} = MapSchemaValidator.validate(schema, map)\n```\n\n**List of allowed values and list of values**\n\n```elixir\nschema = %{\n  value_list: [:string, :number],\n}\nmap = %{\n  value_list: [\"value string\", 1],\n}\n\n{:ok, _} = MapSchemaValidator.validate(schema, map)\n```\n\n**List of maps with format**\n\n```elixir\nschema = %{\n  list: [\n    %{\n      inner_value: :string,\n      inner_map: %{\n        inner_value: :string\n      },\n      inner_list: [\n        %{\n          inner_value_level_2: :number\n        }\n      ]\n    }  \n  ]\n}\nmap = %{\n  list: [\n    %{\n      inner_value: \"value string\",\n      inner_map: %{\n        inner_value: \"value string\"\n      },\n      inner_list: [\n        %{\n          inner_value_level_2: 100\n        }\n      ]\n    }  \n  ]\n}\n\n{:ok, _} = MapSchemaValidator.validate(schema, map)\n```\n\n\u003e In this case are allowed just one schema per list, multiple are work in progress\n\n## Advanced example\n\n```elixir\nschema = %{\n  list: [\n    %{\n      inner_field: [:string, :number],\n      inner_list: [\n        %{\n          inner_leven_2_flag: [:boolean, :integer]\n        }\n      ],\n      inner_optional_flag?: :boolean\n    }\n  ]\n}\nmap = %{\n  list: [\n    %{\n      inner_field: \"value string\",\n      inner_list: [\n        %{\n          inner_leven_2_flag: true\n        }\n      ],\n      inner_optional_flag: false\n    },\n    %{\n      inner_field: 10,\n      inner_list: [\n        %{\n          inner_leven_2_flag: true\n        }\n      ]\n    }\n  ]\n}\n\n{:ok, _} = MapSchemaValidator.validate(schema, map)\n\ndefmodule InnerListElementModule do\n  use MapSchemaValidator.Schema\n\n  field :inner_leven_2_flag, [:boolean, :integer]\nend\n\ndefmodule ListElementModule do\n  use MapSchemaValidator.Schema\n\n  field :inner_field, [:string, :number]\n  field :inner_list, [InnerListElementModule]\n  field :inner_optional_flag?, :boolean\nend\n\ndefmodule SchemaModule do\n  use MapSchemaValidator.Schema\n\n  field :list, [ListElementModule]\nend\n\n{:ok, _} = SchemaModule.validate(map)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolkill%2Fmap_schema_validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicolkill%2Fmap_schema_validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolkill%2Fmap_schema_validator/lists"}