{"action":"opened","issue":{"url":"https://api.github.com/repos/epoberezkin/ajv/issues/380","repository_url":"https://api.github.com/repos/epoberezkin/ajv","labels_url":"https://api.github.com/repos/epoberezkin/ajv/issues/380/labels{/name}","comments_url":"https://api.github.com/repos/epoberezkin/ajv/issues/380/comments","events_url":"https://api.github.com/repos/epoberezkin/ajv/issues/380/events","html_url":"https://github.com/epoberezkin/ajv/issues/380","id":197451785,"number":380,"title":"`normalizeId` fails when id is not string","user":{"login":"scott-martin","id":2068545,"avatar_url":"https://avatars.githubusercontent.com/u/2068545?v=3","gravatar_id":"","url":"https://api.github.com/users/scott-martin","html_url":"https://github.com/scott-martin","followers_url":"https://api.github.com/users/scott-martin/followers","following_url":"https://api.github.com/users/scott-martin/following{/other_user}","gists_url":"https://api.github.com/users/scott-martin/gists{/gist_id}","starred_url":"https://api.github.com/users/scott-martin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scott-martin/subscriptions","organizations_url":"https://api.github.com/users/scott-martin/orgs","repos_url":"https://api.github.com/users/scott-martin/repos","events_url":"https://api.github.com/users/scott-martin/events{/privacy}","received_events_url":"https://api.github.com/users/scott-martin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-24T06:54:40Z","updated_at":"2016-12-24T06:54:40Z","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.10.2\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  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\r\n  \"type\": \"object\",\r\n  \"properties\": {\r\n    \"id\": {\r\n      \"type\": \"integer\"\r\n    },\r\n    \"first_name\": {\r\n      \"type\": \"string\",\r\n      \"minLength\": 1,\r\n      \"maxLength\": 50\r\n    },\r\n    \"last_name\": {\r\n      \"type\": \"string\",\r\n      \"minLength\": 1,\r\n      \"maxLength\": 50\r\n    },\r\n    \"phone_number\": {\r\n      \"type\": \"string\",\r\n      \"format\": \"phone\"\r\n    },\r\n  },\r\n  \"required\": [\r\n    \"id\",\r\n    \"first_name\",\r\n    \"last_name\",\r\n    \"phone_number\"\r\n  ]\r\n}\r\n```\r\n\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  \"id\": 1,\r\n  \"first_name\": \"Draco\",\r\n  \"last_name\": \"Malfoy\",\r\n  \"phone_number\": \"+18434890026\"\r\n}                   \r\n```\r\n\r\n**Your code (please use `options`, `schema` and `data` as variables):**\r\n\r\n```javascript\r\n\r\n'use strict';\r\n\r\nconst Ajv = require('ajv');\r\nconst schema = require('./contact.schema');\r\nlet ajv = Ajv({ allErrors: true });\r\najv.addFormat('phone', () => { return true; });\r\najv.compile(schema);\r\n\r\nexports.validate = function (data) {\r\n    ajv.validate(data);\r\n    return ajv.errors;\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**Validation result, data AFTER validation, error messages:**\r\n\r\n```\r\nTypeError: id.replace is not a function\r\n    at Function.normalizeId (/XXXX/node_modules/ajv/lib/compile/resolve.js:216:18)\r\n    at _addSchema (/XXXX/node_modules/ajv/lib/ajv.js:282:22)\r\n    at Ajv.validate (/XXXX/node_modules/ajv/lib/ajv.js:94:23)\r\n```\r\n\r\nCurrently using integer ids in my project. As you can see, ajv is failing because there is no `replace` function on the integer type in Javascript."}}
{"actor":{"display_login":"scott-martin"}}