{"name":"jest-validate","version":"30.0.0-beta.2","license":"MIT","_id":"jest-validate@30.0.0-beta.2","maintainers":[{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"cpojer","email":"christoph.pojer@gmail.com"},{"name":"aaronabramov","email":"aaron@abramov.io"},{"name":"openjs-operations","email":"operations@openjsf.org"}],"dist":{"shasum":"aafdc5708823901bba42e64a561aeeec7fe33b30","tarball":"http://registry-npm.ywwl.com/jest-validate/download/jest-validate-30.0.0-beta.2.tgz","fileCount":6,"integrity":"sha512-RUUdHYvn7ri10WXtr9DpZ9/NVJ5QylmiKU6DPboy41obr21fXBBxlI7dkUIUkg7gCE8z9M9s1gJyxfm+b8ErLA==","signatures":[{"sig":"MEYCIQCdPDkMgnw3mZNmeOdasRJzh7iUbJCY68bVmL2dw54CVQIhAP8XPu3jCBEcj71tnvc3o7bz9/p2QqNEuW/6578TjEAT","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30192,"size":7741,"noattachment":false,"key":"/jest-validate/-/jest-validate-30.0.0-beta.2.tgz"},"main":"./build/index.js","types":"./build/index.d.ts","engines":{"node":"^18.14.0 || ^20.0.0 || >=22.0.0"},"exports":{".":{"types":"./build/index.d.ts","import":"./build/index.mjs","default":"./build/index.js","require":"./build/index.js"},"./package.json":"./package.json"},"gitHead":"53a5635ac9a43099033f6103e179b13a5465e017","_npmUser":{"name":"cpojer","email":"christoph.pojer@gmail.com"},"repository":{"url":"https://github.com/jestjs/jest.git","type":"git","directory":"packages/jest-validate"},"_npmVersion":"lerna/3.12.3/node@v23.11.0+arm64 (darwin)","directories":{},"_nodeVersion":"23.11.0","dependencies":{"chalk":"^4.0.0","leven":"^3.1.0","camelcase":"^6.2.0","@jest/types":"30.0.0-beta.1","pretty-format":"30.0.0-beta.1","@jest/get-type":"30.0.0-beta.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/yargs":"^17.0.8"},"_npmOperationalInternal":{"tmp":"tmp/jest-validate_30.0.0-beta.2_1748308995988_0.5596980259257909","host":"s3://npm-registry-packages-npm-production"},"readme":"# jest-validate\n\nGeneric configuration validation tool that helps you with warnings, errors and deprecation messages as well as showing users examples of correct configuration.\n\n```bash\nnpm install --save jest-validate\n```\n\n## Usage\n\n```js\nimport {validate} from 'jest-validate';\n\nvalidate(config, validationOptions); // => {hasDeprecationWarnings: boolean, isValid: boolean}\n```\n\nWhere `ValidationOptions` are:\n\n```ts\ntype ValidationOptions = {\n  comment?: string;\n  condition?: (option: unknown, validOption: unknown) => boolean;\n  deprecate?: (\n    config: Record<string, unknown>,\n    option: string,\n    deprecatedOptions: DeprecatedOptions,\n    options: ValidationOptions,\n  ) => boolean;\n  deprecatedConfig?: DeprecatedOptions;\n  error?: (\n    option: string,\n    received: unknown,\n    defaultValue: unknown,\n    options: ValidationOptions,\n    path?: Array<string>,\n  ) => void;\n  exampleConfig: Record<string, unknown>;\n  recursive?: boolean;\n  recursiveBlacklist?: Array<string>;\n  recursiveDenylist?: Array<string>;\n  title?: Title;\n  unknown?: (\n    config: Record<string, unknown>,\n    exampleConfig: Record<string, unknown>,\n    option: string,\n    options: ValidationOptions,\n    path?: Array<string>,\n  ) => void;\n};\n\ntype Title = {\n  deprecation?: string;\n  error?: string;\n  warning?: string;\n};\n```\n\n`exampleConfig` is the only option required.\n\n## API\n\nBy default `jest-validate` will print generic warning and error messages. You can however customize this behavior by providing `options: ValidationOptions` object as a second argument:\n\nAlmost anything can be overwritten to suite your needs.\n\n### Options\n\n- `recursiveDenylist` – optional array of string keyPaths that should be excluded from deep (recursive) validation.\n- `comment` – optional string to be rendered below error/warning message.\n- `condition` – an optional function with validation condition.\n- `deprecate`, `error`, `unknown` – optional functions responsible for displaying warning and error messages.\n- `deprecatedConfig` – optional object with deprecated config keys.\n- `exampleConfig` – the only **required** option with configuration against which you'd like to test.\n- `recursive` - optional boolean determining whether recursively compare `exampleConfig` to `config` (default: `true`).\n- `title` – optional object of titles for errors and messages.\n\nYou will find examples of `condition`, `deprecate`, `error`, `unknown`, and `deprecatedConfig` inside source of this repository, named respectively.\n\n## exampleConfig syntax\n\n`exampleConfig` should be an object with key/value pairs that contain an example of a valid value for each key. A configuration value is considered valid when:\n\n- it matches the JavaScript type of the example value, e.g. `string`, `number`, `array`, `boolean`, `function`, or `object`\n- it is `null` or `undefined`\n- it matches the Javascript type of any of arguments passed to `MultipleValidOptions(...)`\n\nThe last condition is a special syntax that allows validating where more than one type is permissible; see example below. It's acceptable to have multiple values of the same type in the example, so you can also use this syntax to provide more than one example. When a validation failure occurs, the error message will show all other values in the array as examples.\n\n## Examples\n\nMinimal example:\n\n```js\nvalidate(config, {exampleConfig});\n```\n\nExample with slight modifications:\n\n```js\nvalidate(config, {\n  comment: '  Documentation: http://custom-docs.com',\n  deprecatedConfig,\n  exampleConfig,\n  title: {\n    deprecation: 'Custom Deprecation',\n    // leaving 'error' and 'warning' as default\n  },\n});\n```\n\nThis will output:\n\n#### Warning:\n\n```bash\n● Validation Warning:\n\n  Unknown option transformx with value \"<rootDir>/node_modules/babel-jest\" was found.\n  This is either a typing error or a user mistake. Fixing it will remove this message.\n\n  Documentation: http://custom-docs.com\n```\n\n#### Error:\n\n```bash\n● Validation Error:\n\n  Option transform must be of type:\n    object\n  but instead received:\n    string\n\n  Example:\n  {\n    \"transform\": {\n      \"\\\\.js$\": \"<rootDir>/preprocessor.js\"\n    }\n  }\n\n  Documentation: http://custom-docs.com\n```\n\n## Example validating multiple types\n\n```js\nimport {multipleValidOptions} from 'jest-validate';\n\nvalidate(config, {\n  // `bar` will accept either a string or a number\n  bar: multipleValidOptions('string is ok', 2),\n});\n```\n\n#### Error:\n\n```bash\n● Validation Error:\n\n  Option foo must be of type:\n    string or number\n  but instead received:\n    array\n\n  Example:\n  {\n    \"bar\": \"string is ok\"\n  }\n\n  or\n\n  {\n    \"bar\": 2\n  }\n\n  Documentation: http://custom-docs.com\n```\n\n#### Deprecation\n\nBased on `deprecatedConfig` object with proper deprecation messages. Note custom title:\n\n```bash\nCustom Deprecation:\n\n  Option scriptPreprocessor was replaced by transform, which support multiple preprocessors.\n\n  Jest now treats your current configuration as:\n  {\n    \"transform\": {\".*\": \"xxx\"}\n  }\n\n  Please update your configuration.\n\n  Documentation: http://custom-docs.com\n```\n\n## Example validating CLI arguments\n\n```js\nimport {validate} from 'jest-validate';\n\nvalidateCLIOptions(argv, {...allowedOptions, deprecatedOptions});\n```\n\nIf `argv` contains a deprecated option that is not specified in `allowedOptions`, `validateCLIOptions` will throw an error with the message specified in the `deprecatedOptions` config:\n\n```bash\n● collectCoverageOnlyFrom:\n\n  Option \"collectCoverageOnlyFrom\" was replaced by \"collectCoverageFrom\"\n\n  CLI Options Documentation: https://jestjs.io/docs/en/cli.html\n```\n\nIf the deprecation option is still listed in the `allowedOptions` config, then `validateCLIOptions` will print the warning without throwing an error.\n","publish_time":1748308996156,"_cnpm_publish_time":1748308996156,"dist-tags":{"latest":"30.5.1","next":"30.0.0-rc.1"}}