{"id":15233405,"url":"https://github.com/ext/better-ajv-errors","last_synced_at":"2025-10-04T18:31:41.122Z","repository":{"id":40353483,"uuid":"226744599","full_name":"ext/better-ajv-errors","owner":"ext","description":"JSON Schema validation for Human 👨‍🎤","archived":false,"fork":true,"pushed_at":"2024-10-29T17:24:10.000Z","size":5441,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T18:47:16.812Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://atlassian.github.io/better-ajv-errors/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"atlassian/better-ajv-errors","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ext.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-12-08T23:02:10.000Z","updated_at":"2024-10-29T17:23:28.000Z","dependencies_parsed_at":"2023-09-24T00:30:22.147Z","dependency_job_id":null,"html_url":"https://github.com/ext/better-ajv-errors","commit_stats":{"total_commits":667,"total_committers":23,"mean_commits":29.0,"dds":0.5892053973013494,"last_synced_commit":"765e1a2280183e9b59292e2c28daf754d382f6f1"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ext%2Fbetter-ajv-errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ext%2Fbetter-ajv-errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ext%2Fbetter-ajv-errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ext%2Fbetter-ajv-errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ext","download_url":"https://codeload.github.com/ext/better-ajv-errors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235289302,"owners_count":18965918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-09-29T05:08:38.474Z","updated_at":"2025-10-04T18:31:41.102Z","avatar_url":"https://github.com/ext.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cimg width=\"570\" src=\"media/logo.png\" alt=\"better-ajv-errors\"\u003e\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n\u003e JSON Schema validation for Human 👨‍🎤\n\nMain goal of this library is to provide relevant error messages like the following:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"media/screenshot.svg\"\u003e\n\u003c/p\u003e\n\n## Fork\n\nThis fork removes the legacy build and thus drops dependencies such as `core-js`\nand `@babel/runtime` which is not needed on modern installations.\n\n- Node 12 and later supports the modern build and according to the release plan\n  node 10 was EOL at 2021-04-30.\n- Earlier versions is already EOL and not supported. Anyone using it should\n  update instead.\n\nThe following PRs from upstream are merged:\n\n- [PR-85: fix: enumeration in anyOf](https://github.com/atlassian/better-ajv-errors/pull/85)\n- ~[PR-67: fix(typings): Correct TypeScript type definition](https://github.com/atlassian/better-ajv-errors/pull/67)~ (superseeded by upstream fix)\n- ~[PR-70: Drop legacy build and dependecy on polyfills](https://github.com/atlassian/better-ajv-errors/pull/70)~ (dropped in favour of esbuild)\n\nThe following PRs has been merged upstream:\n\n- [PR-84: feat: support `json` option to get accurate line/column listings](https://github.com/atlassian/better-ajv-errors/pull/84)\n- [PR-92: feat: ajv 8 support](https://github.com/atlassian/better-ajv-errors/pull/92)\n\n## Installation\n\n```bash\n$ npm i @sidvind/better-ajv-errors\n```\n\nAlso make sure that you installed [ajv](https://www.npmjs.com/package/ajv) package to validate data against JSON schemas.\n\n## Usage\n\nFirst, you need to validate your payload with `ajv`. If it's invalid then you can pass `validate.errors` object into `better-ajv-errors`.\n\n```js\nimport Ajv from 'ajv';\nimport betterAjvErrors from '@sidvind/better-ajv-errors';\n// const Ajv = require('ajv');\n// const betterAjvErrors = require('@sidvind/better-ajv-errors').default;\n// Or\n// const { default: betterAjvErrors } = require('@sidvid/better-ajv-errors');\n\n// You need to pass `{ jsonPointers: true }` for older versions of ajv\nconst ajv = new Ajv();\n\n// Load schema and data\nconst schema = ...;\nconst data = ...;\n\nconst validate = ajv.compile(schema);\nconst valid = validate(data);\n\nif (!valid) {\n  const output = betterAjvErrors(schema, data, validate.errors);\n  console.log(output);\n}\n```\n\n## API\n\n### betterAjvErrors(schema, data, errors, [options])\n\nReturns formatted validation error to **print** in `console`. See [`options.format`](#format) for further details.\n\n#### schema\n\nType: `Object`\n\nThe JSON Schema you used for validation with `ajv`\n\n#### data\n\nType: `Object`\n\nThe JSON payload you validate against using `ajv`\n\n#### errors\n\nType: `Array`\n\nArray of [ajv validation errors](https://github.com/epoberezkin/ajv#validation-errors)\n\n#### options\n\nType: `Object`\n\n##### format\n\nType: `string`  \nDefault: `cli`  \nValues: `cli` `js`\n\nUse default `cli` output format if you want to **print** beautiful validation errors like following:\n\n\u003cimg width=\"620\" src=\"media/screenshot.svg\"\u003e\n\nOr, use `js` if you are planning to use this with some API. Your output will look like following:\n\n```javascript\n[\n  {\n    start: { line: 6, column: 15, offset: 70 },\n    end: { line: 6, column: 26, offset: 81 },\n    error: \"/content/0/type should be equal to one of the allowed values: panel, paragraph, ...\",\n    suggestion: \"Did you mean paragraph?\",\n  },\n];\n```\n\n##### indent\n\nType: `number` `null`  \nDefault: `null`\n\nIf you have an unindented JSON payload and you want the error output indented.\n\nThis option have no effect when using the `json` option.\n\n##### json\n\nType: `string` `null`  \nDefault: `null`\n\nRaw JSON payload used when formatting codeframe.\nGives accurate line and column listings.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fext%2Fbetter-ajv-errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fext%2Fbetter-ajv-errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fext%2Fbetter-ajv-errors/lists"}