{"action":"created","issue":{"url":"https://api.github.com/repos/eclipsesource/play-json-schema-validator/issues/53","repository_url":"https://api.github.com/repos/eclipsesource/play-json-schema-validator","labels_url":"https://api.github.com/repos/eclipsesource/play-json-schema-validator/issues/53/labels{/name}","comments_url":"https://api.github.com/repos/eclipsesource/play-json-schema-validator/issues/53/comments","events_url":"https://api.github.com/repos/eclipsesource/play-json-schema-validator/issues/53/events","html_url":"https://github.com/eclipsesource/play-json-schema-validator/issues/53","id":159242111,"number":53,"title":"Don't care about the key, but what type its value should be","user":{"login":"barbaragomes","id":13023284,"avatar_url":"https://avatars.githubusercontent.com/u/13023284?v=3","gravatar_id":"","url":"https://api.github.com/users/barbaragomes","html_url":"https://github.com/barbaragomes","followers_url":"https://api.github.com/users/barbaragomes/followers","following_url":"https://api.github.com/users/barbaragomes/following{/other_user}","gists_url":"https://api.github.com/users/barbaragomes/gists{/gist_id}","starred_url":"https://api.github.com/users/barbaragomes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barbaragomes/subscriptions","organizations_url":"https://api.github.com/users/barbaragomes/orgs","repos_url":"https://api.github.com/users/barbaragomes/repos","events_url":"https://api.github.com/users/barbaragomes/events{/privacy}","received_events_url":"https://api.github.com/users/barbaragomes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-06-08T18:43:57Z","updated_at":"2016-06-09T20:16:01Z","closed_at":null,"body":"Hey there,\r\n\r\nnot sure where to look for the answer so I'm posting it here.\r\nI need to validate a JSON object that can contain any key name, but its value should be of type \"string\".\r\nSo basically I don't care about the key or how many keys I can have, but I must specify that the correspondent value should be a string.\r\n\r\nIs there any way to specify that?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/eclipsesource/play-json-schema-validator/issues/comments/225013100","html_url":"https://github.com/eclipsesource/play-json-schema-validator/issues/53#issuecomment-225013100","issue_url":"https://api.github.com/repos/eclipsesource/play-json-schema-validator/issues/53","id":225013100,"user":{"login":"edgarmueller","id":711092,"avatar_url":"https://avatars.githubusercontent.com/u/711092?v=3","gravatar_id":"","url":"https://api.github.com/users/edgarmueller","html_url":"https://github.com/edgarmueller","followers_url":"https://api.github.com/users/edgarmueller/followers","following_url":"https://api.github.com/users/edgarmueller/following{/other_user}","gists_url":"https://api.github.com/users/edgarmueller/gists{/gist_id}","starred_url":"https://api.github.com/users/edgarmueller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edgarmueller/subscriptions","organizations_url":"https://api.github.com/users/edgarmueller/orgs","repos_url":"https://api.github.com/users/edgarmueller/repos","events_url":"https://api.github.com/users/edgarmueller/events{/privacy}","received_events_url":"https://api.github.com/users/edgarmueller/received_events","type":"User","site_admin":false},"created_at":"2016-06-09T20:16:01Z","updated_at":"2016-06-09T20:16:01Z","body":"I think both cases can be solved by using `patternProperties`, here's some example code for the first example:\r\n\r\n```Scala\r\nval schema = JsonSource.schemaFromString(\r\n      \"\"\"{\r\n        |  \"properties\": {\r\n        |    \"parameters\": {\r\n        |      \"patternProperties\": {\r\n        |        \".*\": {\"type\": \"string\"}\r\n        |      }\r\n        |    }\r\n        | }\r\n        |}\"\"\".stripMargin).get\r\n\r\nSchemaValidator.validate(schema,\r\n  Json.obj(\r\n    \"parameters\" -> Json.obj(\r\n      \"param1\" -> \"bar\",\r\n      \"param2\" -> \"foo\"\r\n    )\r\n  )\r\n).isSuccess must beTrue\r\n\r\nSchemaValidator.validate(schema,\r\n  Json.obj(\r\n    \"parameters\" -> Json.obj(\r\n      \"param1\" -> 3,\r\n      \"param2\" -> \"foo\"\r\n    )\r\n  )\r\n).isError must beTrue\r\n```\r\n\r\nYour second example is a little bit more complex, but the following schema should cover that use case as well.\r\n\r\n```Javascript\r\n{\r\n  \"properties\": {\r\n    \"edges\": {\r\n      \"items\": {\r\n        \"patternProperties\": {\r\n          \".*\": {\r\n            \"type\": \"array\",\r\n            \"items\": { \"type\": \"string\" }\r\n          }\r\n        },\r\n        \"maxProperties\": 1\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nDoes this answer your question?"}}
{"actor":{"display_login":"edgarmueller"}}