{
  "_id": "@standard-schema/utils",
  "maintainers": [
    {
      "name": "fabian-hiller",
      "email": "hillerfabian11@gmail.com"
    },
    {
      "name": "colinhacks",
      "email": "colinmcd94@gmail.com"
    }
  ],
  "keywords": [
    "standard",
    "schema",
    "utils"
  ],
  "dist-tags": {
    "latest": "0.3.0"
  },
  "author": {
    "name": "Fabian Hiller"
  },
  "_rev": "4-ea406c598f3401810c168e8b4f1e0ba4",
  "description": "The official runtime utils for Standard Schema",
  "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```",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/standard-schema/standard-schema.git"
  },
  "bugs": {
    "url": "https://github.com/standard-schema/standard-schema/issues"
  },
  "license": "MIT",
  "versions": {
    "0.1.0": {
      "name": "@standard-schema/utils",
      "version": "0.1.0",
      "keywords": [
        "standard",
        "schema",
        "utils"
      ],
      "author": {
        "name": "Fabian Hiller"
      },
      "license": "MIT",
      "_id": "@standard-schema/utils@0.1.0",
      "maintainers": [
        {
          "name": "fabian-hiller",
          "email": "hillerfabian11@gmail.com"
        },
        {
          "name": "colinhacks",
          "email": "colinmcd94@gmail.com"
        }
      ],
      "homepage": "https://github.com/standard-schema/standard-schema#readme",
      "bugs": {
        "url": "https://github.com/standard-schema/standard-schema/issues"
      },
      "dist": {
        "shasum": "1bb6998ee2abee37300d1121acb984a98fbf57bc",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/@standard-schema/utils/-/utils-0.1.0.tgz",
        "fileCount": 7,
        "integrity": "sha512-aszjDe1Jof2Jj+jUufEhvmDHIygHwNajN7UGgj3gq83CYAOugIZHf8F/3OgVbLt+/IaXiH6CRgX5i0DSanecww==",
        "signatures": [
          {
            "sig": "MEQCIHF6EU+yU5mrCFpztm90qoPMwWLMG3EAFB6FoewZ+3WYAiAs/Xvid7J2lSLZv/NaWDFW+Y0EbjOPQiBA5NC0Rj9g7Q==",
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
          }
        ],
        "unpackedSize": 8680
      },
      "main": "./dist/index.js",
      "type": "module",
      "_from": "file:standard-schema-utils-0.1.0.tgz",
      "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"
          }
        }
      },
      "scripts": {
        "lint": "pnpm biome lint ./src",
        "test": "vitest",
        "build": "tsup",
        "check": "pnpm biome check ./src",
        "format": "pnpm biome format --write ./src",
        "coverage": "vitest run --coverage --isolate"
      },
      "_npmUser": {
        "name": "fabian-hiller",
        "email": "hillerfabian11@gmail.com"
      },
      "_resolved": "/private/var/folders/mj/63qb596913q2knjvxp5ww7tc0000gn/T/ac61d3b679a95494726c0a50fe44995a/standard-schema-utils-0.1.0.tgz",
      "_integrity": "sha512-aszjDe1Jof2Jj+jUufEhvmDHIygHwNajN7UGgj3gq83CYAOugIZHf8F/3OgVbLt+/IaXiH6CRgX5i0DSanecww==",
      "repository": {
        "url": "git+https://github.com/standard-schema/standard-schema.git",
        "type": "git"
      },
      "_npmVersion": "10.8.0",
      "description": "The official runtime utils for Standard Schema",
      "directories": {},
      "sideEffects": false,
      "_nodeVersion": "20.11.0",
      "publishConfig": {
        "access": "public"
      },
      "_hasShrinkwrap": false,
      "devDependencies": {
        "tsup": "^8.3.0",
        "vite": "^5.4.8",
        "vitest": "^2.1.2",
        "typescript": "^5.6.2",
        "@vitest/coverage-v8": "2.1.2",
        "@standard-schema/spec": "npm:@jsr/standard-schema__spec@1.0.0-beta.0"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/utils_0.1.0_1728191067011_0.055038870241869375",
        "host": "s3://npm-registry-packages"
      }
    },
    "0.1.1": {
      "name": "@standard-schema/utils",
      "version": "0.1.1",
      "keywords": [
        "standard",
        "schema",
        "utils"
      ],
      "author": {
        "name": "Fabian Hiller"
      },
      "license": "MIT",
      "_id": "@standard-schema/utils@0.1.1",
      "maintainers": [
        {
          "name": "fabian-hiller",
          "email": "hillerfabian11@gmail.com"
        },
        {
          "name": "colinhacks",
          "email": "colinmcd94@gmail.com"
        }
      ],
      "homepage": "https://github.com/standard-schema/standard-schema#readme",
      "bugs": {
        "url": "https://github.com/standard-schema/standard-schema/issues"
      },
      "dist": {
        "shasum": "46a957691d3b8c1aabae65968efce927e4c5ed91",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/@standard-schema/utils/-/utils-0.1.1.tgz",
        "fileCount": 7,
        "integrity": "sha512-Uc/EWqUoxElTp50GChAK4l/QTn82RiSMsJB9dtUiIo54HHCpxByOxBGAOh73J1AGxMjk1ALvlDCyueOdvaxxPw==",
        "signatures": [
          {
            "sig": "MEUCIQCM2WZFs5zoWiHvh3WgQX5MpXgijVRnT2Vv8kr/vHXCkAIgJ1e9HRBU43NxQ45AEK4ofbrLmIzj6cqvvuwgRaZq2L4=",
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
          }
        ],
        "attestations": {
          "url": "https://registry.npmjs.org/-/npm/v1/attestations/@standard-schema%2futils@0.1.1",
          "provenance": {
            "predicateType": "https://slsa.dev/provenance/v1"
          }
        },
        "unpackedSize": 8694
      },
      "main": "./dist/index.js",
      "type": "module",
      "_from": "file:standard-schema-utils-0.1.1.tgz",
      "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"
          }
        }
      },
      "scripts": {
        "lint": "pnpm biome lint ./src",
        "test": "vitest",
        "build": "tsup",
        "check": "pnpm biome check ./src",
        "format": "pnpm biome format --write ./src",
        "coverage": "vitest run --coverage --isolate"
      },
      "_npmUser": {
        "name": "fabian-hiller",
        "email": "hillerfabian11@gmail.com"
      },
      "_resolved": "/tmp/c4ccea1010b6c983e06f148c625686e9/standard-schema-utils-0.1.1.tgz",
      "_integrity": "sha512-Uc/EWqUoxElTp50GChAK4l/QTn82RiSMsJB9dtUiIo54HHCpxByOxBGAOh73J1AGxMjk1ALvlDCyueOdvaxxPw==",
      "repository": {
        "url": "git+https://github.com/standard-schema/standard-schema.git",
        "type": "git"
      },
      "_npmVersion": "10.8.2",
      "description": "The official runtime utils for Standard Schema",
      "directories": {},
      "sideEffects": false,
      "_nodeVersion": "20.17.0",
      "publishConfig": {
        "access": "public"
      },
      "_hasShrinkwrap": false,
      "devDependencies": {
        "tsup": "^8.3.0",
        "vite": "^5.4.8",
        "vitest": "^2.1.2",
        "typescript": "^5.6.2",
        "@vitest/coverage-v8": "2.1.2",
        "@standard-schema/spec": "npm:@jsr/standard-schema__spec@1.0.0-beta.0"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/utils_0.1.1_1728228324040_0.7770303364983446",
        "host": "s3://npm-registry-packages"
      }
    },
    "0.2.0": {
      "name": "@standard-schema/utils",
      "version": "0.2.0",
      "keywords": [
        "standard",
        "schema",
        "utils"
      ],
      "author": {
        "name": "Fabian Hiller"
      },
      "license": "MIT",
      "_id": "@standard-schema/utils@0.2.0",
      "maintainers": [
        {
          "name": "fabian-hiller",
          "email": "hillerfabian11@gmail.com"
        },
        {
          "name": "colinhacks",
          "email": "colinmcd94@gmail.com"
        }
      ],
      "homepage": "https://github.com/standard-schema/standard-schema#readme",
      "bugs": {
        "url": "https://github.com/standard-schema/standard-schema/issues"
      },
      "dist": {
        "shasum": "fbf46abb440cdb974d3f044553b8ca3984079bd2",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/@standard-schema/utils/-/utils-0.2.0.tgz",
        "fileCount": 7,
        "integrity": "sha512-JSkqtPD1pkZW9NYHxfbI2cIMpbqFrOzPZOvNklyhsaM9gY5l0vHG2twIM8uA7ONLy6PzVzy2DKkbEDOGSocw8A==",
        "signatures": [
          {
            "sig": "MEQCIFoxL7ZlDPgYhK8Y8vpgv9Zk9D5ibb9bYrSH/aqzirF8AiAhuht5RtYI6LBJYNayVJzmFNTmnBHg00xwNMIWfG9z5g==",
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
          }
        ],
        "attestations": {
          "url": "https://registry.npmjs.org/-/npm/v1/attestations/@standard-schema%2futils@0.2.0",
          "provenance": {
            "predicateType": "https://slsa.dev/provenance/v1"
          }
        },
        "unpackedSize": 8804
      },
      "main": "./dist/index.js",
      "type": "module",
      "_from": "file:standard-schema-utils-0.2.0.tgz",
      "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"
          }
        }
      },
      "scripts": {
        "lint": "pnpm biome lint ./src",
        "test": "vitest",
        "build": "tsup",
        "check": "pnpm biome check ./src",
        "format": "pnpm biome format --write ./src",
        "coverage": "vitest run --coverage --isolate"
      },
      "_npmUser": {
        "name": "fabian-hiller",
        "email": "hillerfabian11@gmail.com"
      },
      "_resolved": "/tmp/184402c246ab529711e29b20fef3c13a/standard-schema-utils-0.2.0.tgz",
      "_integrity": "sha512-JSkqtPD1pkZW9NYHxfbI2cIMpbqFrOzPZOvNklyhsaM9gY5l0vHG2twIM8uA7ONLy6PzVzy2DKkbEDOGSocw8A==",
      "repository": {
        "url": "git+https://github.com/standard-schema/standard-schema.git",
        "type": "git"
      },
      "_npmVersion": "10.8.2",
      "description": "The official runtime utils for Standard Schema",
      "directories": {},
      "sideEffects": false,
      "_nodeVersion": "20.18.0",
      "publishConfig": {
        "access": "public"
      },
      "_hasShrinkwrap": false,
      "devDependencies": {
        "tsup": "^8.3.0",
        "vite": "^5.4.8",
        "vitest": "^2.1.2",
        "typescript": "^5.6.2",
        "@vitest/coverage-v8": "2.1.2",
        "@standard-schema/spec": "npm:@jsr/standard-schema__spec@1.0.0-beta.2"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/utils_0.2.0_1731034595416_0.5011420333710015",
        "host": "s3://npm-registry-packages"
      }
    },
    "0.2.1": {
      "name": "@standard-schema/utils",
      "version": "0.2.1",
      "keywords": [
        "standard",
        "schema",
        "utils"
      ],
      "author": {
        "name": "Fabian Hiller"
      },
      "license": "MIT",
      "_id": "@standard-schema/utils@0.2.1",
      "maintainers": [
        {
          "name": "fabian-hiller",
          "email": "hillerfabian11@gmail.com"
        },
        {
          "name": "colinhacks",
          "email": "colinmcd94@gmail.com"
        }
      ],
      "homepage": "https://github.com/standard-schema/standard-schema#readme",
      "bugs": {
        "url": "https://github.com/standard-schema/standard-schema/issues"
      },
      "dist": {
        "shasum": "fb4245be7a19c5b3b337fbcb09b9c0a88019d5e0",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/@standard-schema/utils/-/utils-0.2.1.tgz",
        "fileCount": 7,
        "integrity": "sha512-Vq2UmL3Nc7BG9lD7xILL+UmuCkU9s4x66OAiLBCab46S60dfVyZoiPNuLmr4Gjoo0Eaw6/bzzrDAp02R/NHVgA==",
        "signatures": [
          {
            "sig": "MEYCIQCZDKYkR7dmZl1Wl5lnj4QgajHlkN12Tkn9n+zaK3JtzQIhAKp2B8gdTZPt54hQzSgJvJsWh3U4kjTMku2M5S2QvTR6",
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
          }
        ],
        "attestations": {
          "url": "https://registry.npmjs.org/-/npm/v1/attestations/@standard-schema%2futils@0.2.1",
          "provenance": {
            "predicateType": "https://slsa.dev/provenance/v1"
          }
        },
        "unpackedSize": 8782
      },
      "main": "./dist/index.js",
      "type": "module",
      "_from": "file:standard-schema-utils-0.2.1.tgz",
      "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"
          }
        }
      },
      "scripts": {
        "lint": "pnpm biome lint ./src",
        "test": "vitest",
        "build": "tsup",
        "check": "pnpm biome check ./src",
        "format": "pnpm biome format --write ./src",
        "coverage": "vitest run --coverage --isolate"
      },
      "_npmUser": {
        "name": "fabian-hiller",
        "email": "hillerfabian11@gmail.com"
      },
      "_resolved": "/tmp/5f3e9935c214053fc7ef25c5a1d22165/standard-schema-utils-0.2.1.tgz",
      "_integrity": "sha512-Vq2UmL3Nc7BG9lD7xILL+UmuCkU9s4x66OAiLBCab46S60dfVyZoiPNuLmr4Gjoo0Eaw6/bzzrDAp02R/NHVgA==",
      "repository": {
        "url": "git+https://github.com/standard-schema/standard-schema.git",
        "type": "git"
      },
      "_npmVersion": "10.8.2",
      "description": "The official runtime utils for Standard Schema",
      "directories": {},
      "sideEffects": false,
      "_nodeVersion": "20.18.0",
      "publishConfig": {
        "access": "public"
      },
      "_hasShrinkwrap": false,
      "devDependencies": {
        "tsup": "^8.3.0",
        "vite": "^5.4.8",
        "vitest": "^2.1.2",
        "typescript": "^5.6.2",
        "@vitest/coverage-v8": "2.1.2",
        "@standard-schema/spec": "npm:@jsr/standard-schema__spec@1.0.0-beta.2"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/utils_0.2.1_1731079199419_0.20068377009492533",
        "host": "s3://npm-registry-packages"
      }
    },
    "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": "https://archive.ito.gov.ir/npm/_packages/@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"
          }
        ]
      },
      "_npmUser": {
        "name": "fabian-hiller",
        "email": "hillerfabian11@gmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "fabian-hiller",
          "email": "hillerfabian11@gmail.com"
        },
        {
          "name": "colinhacks",
          "email": "colinmcd94@gmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages",
        "tmp": "tmp/utils_0.3.0_1732749674712_0.023804735355292594"
      },
      "_hasShrinkwrap": false
    }
  },
  "name": "@standard-schema/utils",
  "time": {
    "created": "2024-10-06T05:04:26.770Z",
    "modified": "2026-05-14T14:40:20.595Z",
    "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"
  },
  "readmeFilename": "README.md",
  "homepage": "https://github.com/standard-schema/standard-schema#readme"
}