{"versions":{"0.1.0":{"name":"@standard-schema/utils","description":"The official runtime utils for Standard Schema","version":"0.1.0","license":"MIT","author":{"name":"Fabian Hiller"},"repository":{"type":"git","url":"git+https://github.com/standard-schema/standard-schema.git"},"keywords":["standard","schema","utils"],"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"sideEffects":false,"publishConfig":{"access":"public"},"devDependencies":{"@standard-schema/spec":"npm:@jsr/standard-schema__spec@1.0.0-beta.0","@vitest/coverage-v8":"2.1.2","tsup":"^8.3.0","typescript":"^5.6.2","vite":"^5.4.8","vitest":"^2.1.2"},"scripts":{"test":"vitest","coverage":"vitest run --coverage --isolate","lint":"pnpm biome lint ./src","format":"pnpm biome format --write ./src","check":"pnpm biome check ./src","build":"tsup"},"_id":"@standard-schema/utils@0.1.0","bugs":{"url":"https://github.com/standard-schema/standard-schema/issues"},"homepage":"https://github.com/standard-schema/standard-schema#readme","_integrity":"sha512-aszjDe1Jof2Jj+jUufEhvmDHIygHwNajN7UGgj3gq83CYAOugIZHf8F/3OgVbLt+/IaXiH6CRgX5i0DSanecww==","_resolved":"/private/var/folders/mj/63qb596913q2knjvxp5ww7tc0000gn/T/ac61d3b679a95494726c0a50fe44995a/standard-schema-utils-0.1.0.tgz","_from":"file:standard-schema-utils-0.1.0.tgz","_nodeVersion":"20.11.0","_npmVersion":"10.8.0","dist":{"integrity":"sha512-aszjDe1Jof2Jj+jUufEhvmDHIygHwNajN7UGgj3gq83CYAOugIZHf8F/3OgVbLt+/IaXiH6CRgX5i0DSanecww==","shasum":"1bb6998ee2abee37300d1121acb984a98fbf57bc","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@standard-schema/utils/-/utils-0.1.0.tgz","fileCount":7,"unpackedSize":8680,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHF6EU+yU5mrCFpztm90qoPMwWLMG3EAFB6FoewZ+3WYAiAs/Xvid7J2lSLZv/NaWDFW+Y0EbjOPQiBA5NC0Rj9g7Q=="}],"size":3074},"_npmUser":{"name":"anonymous","email":"hillerfabian11@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"hillerfabian11@gmail.com"},{"name":"anonymous","email":"colinmcd94@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utils_0.1.0_1728191067011_0.055038870241869375"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-10-06T05:04:27.206Z","publish_time":1728191067206,"_source_registry_name":"default","contributors":[]},"0.1.1":{"name":"@standard-schema/utils","description":"The official runtime utils for Standard Schema","version":"0.1.1","license":"MIT","author":{"name":"Fabian Hiller"},"repository":{"type":"git","url":"git+https://github.com/standard-schema/standard-schema.git"},"keywords":["standard","schema","utils"],"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"sideEffects":false,"publishConfig":{"access":"public"},"devDependencies":{"@standard-schema/spec":"npm:@jsr/standard-schema__spec@1.0.0-beta.0","@vitest/coverage-v8":"2.1.2","tsup":"^8.3.0","typescript":"^5.6.2","vite":"^5.4.8","vitest":"^2.1.2"},"scripts":{"test":"vitest","coverage":"vitest run --coverage --isolate","lint":"pnpm biome lint ./src","format":"pnpm biome format --write ./src","check":"pnpm biome check ./src","build":"tsup"},"_id":"@standard-schema/utils@0.1.1","bugs":{"url":"https://github.com/standard-schema/standard-schema/issues"},"homepage":"https://github.com/standard-schema/standard-schema#readme","_integrity":"sha512-Uc/EWqUoxElTp50GChAK4l/QTn82RiSMsJB9dtUiIo54HHCpxByOxBGAOh73J1AGxMjk1ALvlDCyueOdvaxxPw==","_resolved":"/tmp/c4ccea1010b6c983e06f148c625686e9/standard-schema-utils-0.1.1.tgz","_from":"file:standard-schema-utils-0.1.1.tgz","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Uc/EWqUoxElTp50GChAK4l/QTn82RiSMsJB9dtUiIo54HHCpxByOxBGAOh73J1AGxMjk1ALvlDCyueOdvaxxPw==","shasum":"46a957691d3b8c1aabae65968efce927e4c5ed91","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@standard-schema/utils/-/utils-0.1.1.tgz","fileCount":7,"unpackedSize":8694,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@standard-schema%2futils@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCM2WZFs5zoWiHvh3WgQX5MpXgijVRnT2Vv8kr/vHXCkAIgJ1e9HRBU43NxQ45AEK4ofbrLmIzj6cqvvuwgRaZq2L4="}],"size":3082},"_npmUser":{"name":"anonymous","email":"hillerfabian11@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"hillerfabian11@gmail.com"},{"name":"anonymous","email":"colinmcd94@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utils_0.1.1_1728228324040_0.7770303364983446"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-10-06T15:25:24.248Z","publish_time":1728228324248,"_source_registry_name":"default","contributors":[]},"0.2.0":{"name":"@standard-schema/utils","description":"The official runtime utils for Standard Schema","version":"0.2.0","license":"MIT","author":{"name":"Fabian Hiller"},"repository":{"type":"git","url":"git+https://github.com/standard-schema/standard-schema.git"},"keywords":["standard","schema","utils"],"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"sideEffects":false,"publishConfig":{"access":"public"},"devDependencies":{"@standard-schema/spec":"npm:@jsr/standard-schema__spec@1.0.0-beta.2","@vitest/coverage-v8":"2.1.2","tsup":"^8.3.0","typescript":"^5.6.2","vite":"^5.4.8","vitest":"^2.1.2"},"scripts":{"test":"vitest","coverage":"vitest run --coverage --isolate","lint":"pnpm biome lint ./src","format":"pnpm biome format --write ./src","check":"pnpm biome check ./src","build":"tsup"},"_id":"@standard-schema/utils@0.2.0","bugs":{"url":"https://github.com/standard-schema/standard-schema/issues"},"homepage":"https://github.com/standard-schema/standard-schema#readme","_integrity":"sha512-JSkqtPD1pkZW9NYHxfbI2cIMpbqFrOzPZOvNklyhsaM9gY5l0vHG2twIM8uA7ONLy6PzVzy2DKkbEDOGSocw8A==","_resolved":"/tmp/184402c246ab529711e29b20fef3c13a/standard-schema-utils-0.2.0.tgz","_from":"file:standard-schema-utils-0.2.0.tgz","_nodeVersion":"20.18.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-JSkqtPD1pkZW9NYHxfbI2cIMpbqFrOzPZOvNklyhsaM9gY5l0vHG2twIM8uA7ONLy6PzVzy2DKkbEDOGSocw8A==","shasum":"fbf46abb440cdb974d3f044553b8ca3984079bd2","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@standard-schema/utils/-/utils-0.2.0.tgz","fileCount":7,"unpackedSize":8804,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@standard-schema%2futils@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFoxL7ZlDPgYhK8Y8vpgv9Zk9D5ibb9bYrSH/aqzirF8AiAhuht5RtYI6LBJYNayVJzmFNTmnBHg00xwNMIWfG9z5g=="}],"size":3137},"_npmUser":{"name":"anonymous","email":"hillerfabian11@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"hillerfabian11@gmail.com"},{"name":"anonymous","email":"colinmcd94@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utils_0.2.0_1731034595416_0.5011420333710015"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-11-08T02:56:35.629Z","publish_time":1731034595629,"_source_registry_name":"default","contributors":[]},"0.2.1":{"name":"@standard-schema/utils","description":"The official runtime utils for Standard Schema","version":"0.2.1","license":"MIT","author":{"name":"Fabian Hiller"},"repository":{"type":"git","url":"git+https://github.com/standard-schema/standard-schema.git"},"keywords":["standard","schema","utils"],"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"sideEffects":false,"publishConfig":{"access":"public"},"devDependencies":{"@standard-schema/spec":"npm:@jsr/standard-schema__spec@1.0.0-beta.2","@vitest/coverage-v8":"2.1.2","tsup":"^8.3.0","typescript":"^5.6.2","vite":"^5.4.8","vitest":"^2.1.2"},"scripts":{"test":"vitest","coverage":"vitest run --coverage --isolate","lint":"pnpm biome lint ./src","format":"pnpm biome format --write ./src","check":"pnpm biome check ./src","build":"tsup"},"_id":"@standard-schema/utils@0.2.1","bugs":{"url":"https://github.com/standard-schema/standard-schema/issues"},"homepage":"https://github.com/standard-schema/standard-schema#readme","_integrity":"sha512-Vq2UmL3Nc7BG9lD7xILL+UmuCkU9s4x66OAiLBCab46S60dfVyZoiPNuLmr4Gjoo0Eaw6/bzzrDAp02R/NHVgA==","_resolved":"/tmp/5f3e9935c214053fc7ef25c5a1d22165/standard-schema-utils-0.2.1.tgz","_from":"file:standard-schema-utils-0.2.1.tgz","_nodeVersion":"20.18.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Vq2UmL3Nc7BG9lD7xILL+UmuCkU9s4x66OAiLBCab46S60dfVyZoiPNuLmr4Gjoo0Eaw6/bzzrDAp02R/NHVgA==","shasum":"fb4245be7a19c5b3b337fbcb09b9c0a88019d5e0","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@standard-schema/utils/-/utils-0.2.1.tgz","fileCount":7,"unpackedSize":8782,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@standard-schema%2futils@0.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCZDKYkR7dmZl1Wl5lnj4QgajHlkN12Tkn9n+zaK3JtzQIhAKp2B8gdTZPt54hQzSgJvJsWh3U4kjTMku2M5S2QvTR6"}],"size":3137},"_npmUser":{"name":"anonymous","email":"hillerfabian11@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"hillerfabian11@gmail.com"},{"name":"anonymous","email":"colinmcd94@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utils_0.2.1_1731079199419_0.20068377009492533"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-11-08T15:19:59.592Z","publish_time":1731079199592,"_source_registry_name":"default","contributors":[]},"0.3.0":{"name":"@standard-schema/utils","description":"The official runtime utils for Standard Schema","version":"0.3.0","license":"MIT","author":{"name":"Fabian Hiller"},"repository":{"type":"git","url":"git+https://github.com/standard-schema/standard-schema.git"},"keywords":["standard","schema","utils"],"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"sideEffects":false,"publishConfig":{"access":"public"},"devDependencies":{"@standard-schema/spec":"npm:@jsr/standard-schema__spec@1.0.0-beta.4","@vitest/coverage-v8":"2.1.2","tsup":"^8.3.0","typescript":"^5.6.2","vite":"^5.4.8","vitest":"^2.1.2"},"scripts":{"test":"vitest","coverage":"vitest run --coverage --isolate","lint":"pnpm biome lint ./src","format":"pnpm biome format --write ./src","check":"pnpm biome check ./src","build":"tsup"},"_id":"@standard-schema/utils@0.3.0","bugs":{"url":"https://github.com/standard-schema/standard-schema/issues"},"homepage":"https://github.com/standard-schema/standard-schema#readme","_integrity":"sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==","_resolved":"/tmp/53a111cf8bee8a0ec1c2190be9930fdb/standard-schema-utils-0.3.0.tgz","_from":"file:standard-schema-utils-0.3.0.tgz","_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==","shasum":"3d5e608f16c2390c10528e98e59aef6bf73cae7b","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@standard-schema/utils/-/utils-0.3.0.tgz","fileCount":7,"unpackedSize":8886,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@standard-schema%2futils@0.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDbRyo2SLzI45K40U+e8BGJGT7+D5zBkVfurHx8PHIEDQIhALcR0aGSgk0LwTK8wTbEPHc0tAh9BZXgiEgh0Wye5L1Y"}],"size":3137},"_npmUser":{"name":"anonymous","email":"hillerfabian11@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"hillerfabian11@gmail.com"},{"name":"anonymous","email":"colinmcd94@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utils_0.3.0_1732749674712_0.023804735355292594"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-11-27T23:21:14.935Z","publish_time":1732749674935,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"0.3.0"},"name":"@standard-schema/utils","time":{"created":"2024-10-06T05:05:07.608Z","modified":"2024-11-27T23:22:28.483Z","0.1.0":"2024-10-06T05:04:27.206Z","0.1.1":"2024-10-06T15:25:24.248Z","0.2.0":"2024-11-08T02:56:35.629Z","0.2.1":"2024-11-08T15:19:59.592Z","0.3.0":"2024-11-27T23:21:14.935Z"},"readme":"# Standard Schema Utils\n\nThere are two common tasks that third-party libraries perform after validation fails. The first is to flatten the issues by creating a dot path to more easily associate the issues with the input data. This is commonly used in form libraries. The second is to throw an error that contains all the issue information. To simplify both tasks, Standard Schema also ships a utils package that provides a `getDotPath` function and a `SchemaError` class.\n\n```sh\nnpm install @standard-schema/utils   # npm\nyarn add @standard-schema/utils      # yarn\npnpm add @standard-schema/utils      # pnpm\nbun add @standard-schema/utils       # bun\ndeno add jsr:@standard-schema/utils  # deno\n```\n\n## Get Dot Path\n\nTo generate a dot path, simply pass an issue to the `getDotPath` function. If the issue does not contain a path or the path contains a key that is not of type `string` or `number`, the function returns `null`.\n\n```ts\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { getDotPath } from \"@standard-schema/utils\";\n\nasync function getFormErrors(schema: StandardSchemaV1, data: unknown) {\n  const result = await schema[\"~standard\"].validate(data);\n  const formErrors: string[] = [];\n  const fieldErrors: Record<string, string[]> = {};\n  if (result.issues) {\n    for (const issue of result.issues) {\n      const dotPath = getDotPath(issue);\n      if (dotPath) {\n        if (fieldErrors[dotPath]) {\n          fieldErrors[dotPath].push(issue.message);\n        } else {\n          fieldErrors[dotPath] = [issue.message];\n        }\n      } else {\n        formErrors.push(issue.message);\n      }\n    }\n  }\n  return { formErrors, fieldErrors };\n}\n```\n\n## Schema Error\n\nTo throw an error that contains all issue information, simply pass the issues of the failed schema validation to the `SchemaError` class. The `SchemaError` class extends the `Error` class with an `issues` property that contains all the issues.\n\n```ts\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { SchemaError } from \"@standard-schema/utils\";\n\nasync function validateInput<TSchema extends StandardSchemaV1>(\n  schema: TSchema,\n  data: unknown,\n): Promise<StandardSchemaV1.InferOutput<TSchema>> {\n  const result = await schema[\"~standard\"].validate(data);\n  if (result.issues) {\n    throw new SchemaError(result.issues);\n  }\n  return result.value;\n}\n```","users":{}}