{"id":49823,"library":"z-schema-errors","title":"Z-Schema Errors","description":"z-schema-errors normalizes error messages from Z-Schema JSON Schema validation reports. It transforms nested property paths (e.g., '#/items/[0]' → 'items[0]'), extracts first array params, and allows custom message formatting using macros like {message}, {path}, {description}, and {params[i]}. Supports global context messages and custom extractors for each macro. Version 0.2.1 is the latest; no recent updates. As a thin wrapper around Z-Schema, it only works with that validator. No TypeScript types are provided, and it uses CommonJS.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/dschenkelman/z-schema-errors","tags":["javascript","json-schema","errors"],"install":[{"cmd":"npm install z-schema-errors","lang":"bash","label":"npm"},{"cmd":"yarn add z-schema-errors","lang":"bash","label":"yarn"},{"cmd":"pnpm add z-schema-errors","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: this library processes error reports from Z-Schema validator instances.","package":"z-schema","optional":false}],"imports":[{"note":"Package is CommonJS-only; ESM syntax will fail. Use require().","wrong":"import { init } from 'z-schema-errors';","symbol":"init","correct":"const ZSchemaErrors = require('z-schema-errors');\nconst reporter = ZSchemaErrors.init();"},{"note":"No .default property; the module exports the init function directly as the module.exports.","wrong":"const ZSchemaErrors = require('z-schema-errors').default;","symbol":"ZSchemaErrors (default)","correct":"const ZSchemaErrors = require('z-schema-errors');"},{"note":"init() is a factory function, not a constructor. Do not use new.","wrong":"const reporter = new ZSchemaErrors(options);","symbol":"reporter","correct":"const reporter = ZSchemaErrors.init(options);"}],"quickstart":{"code":"const ZSchema = require('z-schema');\nconst ZSchemaErrors = require('z-schema-errors');\n\nconst validator = new ZSchema();\nconst reporter = ZSchemaErrors.init();\n\nconst json = { name: 'Alice' };\nconst schema = { type: 'object', properties: { age: { type: 'integer' } }, required: ['age'] };\n\nconst isValid = validator.validate(json, schema);\nif (!isValid) {\n  const errorMessage = reporter.extractMessage({ report: validator.lastReport });\n  console.log(errorMessage);\n}\n// Output: \"An error occurred 'Missing required property: age' on property # (Object instance has properties which are not allowed by the schema).\"","lang":"javascript","description":"Shows basic usage: validate JSON with Z-Schema, then use z-schema-errors to generate a human-readable error message."},"warnings":[{"fix":"Use reporter.extractMessage({ report: validator.lastReport }) instead of reporter.extractMessage(validator.lastReport.errors).","message":"The extractMessage method expects an object with a 'report' property, not the raw error array.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider migrating to ajv-errors or manually formatting Z-Schema errors.","message":"The package has not been updated since 2015 and may not support newer Z-Schema versions.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Stick to the documented macros: {message}, {path}, {description}, {params[i]}, {contextMessage}.","message":"Custom format strings must include existing macros; unknown macros are left as-is.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If your schema errors have complex params, verify the output; consider custom extractors.","message":"The 'params' macro only works with the first nested array in the error's params field.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'/items':26 '0':27,29 '0.2.1':59 'allow':35 'around':70 'array':32 'commonj':88 'context':50 'custom':36,53 'descript':44 'e.g':25 'error':4,8,10,93 'extract':30 'extractor':54 'first':31 'format':38 'global':49 'item':28 'javascript':89 'json':16,91 'json-schema':90 'latest':62 'like':41 'macro':40,57 'messag':11,37,42,51 'nest':22 'normal':9 'param':33,46 'path':24,43 'properti':23 'provid':84 'recent':64 'report':19 'schema':3,7,15,17,73,92 'support':48 'thin':68 'transform':21 'type':82 'typescript':81 'updat':65 'use':39,87 'valid':18,79 'version':58 'work':76 'wrapper':69 'z':2,6,14,72 'z-schema':1,13,71 'z-schema-error':5","created_at":"2026-06-07T17:03:47.065737+00:00","updated_at":"2026-06-07T17:03:47.065737+00:00","problems":[{"fix":"Use const ZSchemaErrors = require('z-schema-errors'); then ZSchemaErrors.init();","cause":"Using import { init } from 'z-schema-errors' (ESM) instead of require.","error":"TypeError: ZSchemaErrors.init is not a function"},{"fix":"Call reporter.extractMessage({ report: validator.lastReport })","cause":"Passing validator.lastReport.errors directly to extractMessage instead of { report: validator.lastReport }.","error":"TypeError: Cannot read property 'map' of undefined"},{"fix":"Run npm install z-schema","cause":"z-schema is a peer dependency but not installed.","error":"Cannot find module 'z-schema'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/dschenkelman/z-schema-errors","github":"ssh://git@github.com/dschenkelman/z-schema-errors","docs":null,"changelog":null,"pypi":null,"npm":"z-schema-errors","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}