{"action":"opened","issue":{"url":"https://api.github.com/repos/epoberezkin/ajv/issues/337","repository_url":"https://api.github.com/repos/epoberezkin/ajv","labels_url":"https://api.github.com/repos/epoberezkin/ajv/issues/337/labels{/name}","comments_url":"https://api.github.com/repos/epoberezkin/ajv/issues/337/comments","events_url":"https://api.github.com/repos/epoberezkin/ajv/issues/337/events","html_url":"https://github.com/epoberezkin/ajv/issues/337","id":187612164,"number":337,"title":"Does not pick up default value if defined in $ref definition","user":{"login":"onury","id":3665990,"avatar_url":"https://avatars.githubusercontent.com/u/3665990?v=3","gravatar_id":"","url":"https://api.github.com/users/onury","html_url":"https://github.com/onury","followers_url":"https://api.github.com/users/onury/followers","following_url":"https://api.github.com/users/onury/following{/other_user}","gists_url":"https://api.github.com/users/onury/gists{/gist_id}","starred_url":"https://api.github.com/users/onury/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onury/subscriptions","organizations_url":"https://api.github.com/users/onury/orgs","repos_url":"https://api.github.com/users/onury/repos","events_url":"https://api.github.com/users/onury/events{/privacy}","received_events_url":"https://api.github.com/users/onury/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-07T02:30:07Z","updated_at":"2016-11-07T02:30:07Z","closed_at":null,"body":"<!--\r\nFrequently Asked Questions: https://github.com/epoberezkin/ajv/blob/master/FAQ.md\r\nPlease provide all info and reduce your schema and data to the smallest possible size.\r\n\r\nThis template is for bug reports. For other issues please use:\r\n- a new feature/improvement: http://epoberezkin.github.io/ajv/contribute.html#changes\r\n- browser/compatibility issues: http://epoberezkin.github.io/ajv/contribute.html#compatibility\r\n- JSON-Schema standard: http://epoberezkin.github.io/ajv/contribute.html#json-schema\r\n- Ajv usage questions: https://gitter.im/ajv-validator/ajv\r\n-->\r\n\r\n**What version of Ajv are you using? Does the issue happen if you use the latest version?**\r\n4.8.2\r\n\r\n\r\n**Ajv options object (see https://github.com/epoberezkin/ajv#options):**\r\n\r\n```javascript\r\n{\r\n    allErrors: true,\r\n    format: 'full',\r\n    useDefaults: true\r\n}\r\n```\r\n\r\n\r\n**JSON Schema (please make it as small as possible to reproduce the issue):**\r\n\r\n```json\r\n{\r\n    ...\r\n    \"properties\": {\r\n        \"phone\": {\r\n            \"$ref\": \"#/definitions/optionalPhone\"\r\n        },\r\n        ...\r\n    },\r\n    definitions: {\r\n        \"emptyString\": {\r\n            \"type\": \"string\",\r\n            \"maxLength\": 0\r\n        },\r\n        \"phone\": {\r\n            \"format\": \"phone\",\r\n            \"maxLength\": 15\r\n        },\r\n        \"optionalPhone\": {\r\n            \"anyOf\": [\r\n                {\r\n                    \"format\": \"phone\",\r\n                    \"maxLength\": 15\r\n                },\r\n                {\r\n                    \"$ref\": \"#/definitions/emptyString\"\r\n                }\r\n            ],\r\n            \"default\": \"\"\r\n        }\r\n    }\r\n}\r\n```\r\nAbove will work only if I define `default: \"\"` within `phone`.\r\n\r\n**Data (please make it as small as posssible to reproduce the issue):**\r\n\r\n```json\r\n{}\r\n```\r\n\r\n<!--\r\nIt would help if you post a working code sample in Tonic notebook and include the link here. You can clone this notebook: https://tonicdev.com/esp/ajv-issue.\r\n-->\r\n\r\n\r\n**Validation result, data AFTER validation, error messages:**\r\n\r\nNo errors. Just the default value is not set for `phone`.\r\n\r\n**What results did you expect?**\r\n`{ phone: \"\" }`\r\n\r\n"}}
{"actor":{"display_login":"onury"}}