Socket
Socket
Sign inDemoInstall

jest-validate

Package Overview
Dependencies
12
Maintainers
2
Versions
217
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 20.0.3 to 20.1.0-alpha.1

build/default_config.js

20

build/deprecated.js

@@ -1,2 +0,2 @@

'use strict';var _require =
'use strict';

@@ -13,11 +13,11 @@

require('./utils');const logValidationWarning = _require.logValidationWarning,DEPRECATION = _require.DEPRECATION; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const deprecationMessage = (message, options) => {const comment = options.comment;const name = options.title && options.title.deprecation || DEPRECATION;logValidationWarning(name, message, comment);};
var _utils = require('./utils'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const deprecationMessage = (message, options) => {const comment = options.comment;const name = options.title && options.title.deprecation || _utils.DEPRECATION;(0, _utils.logValidationWarning)(name, message, comment);};
const deprecationWarning = (

@@ -24,0 +24,0 @@ config,

@@ -13,30 +13,30 @@ 'use strict';

const chalk = require('chalk'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/var _require = require('jest-matcher-utils');const getType = _require.getType;var _require2 = require('./utils');const format = _require2.format,ValidationError = _require2.ValidationError,ERROR = _require2.ERROR;const errorMessage = (option, received, defaultValue, options) =>
{
const message = ` Option ${chalk.bold(`"${option}"`)} must be of type:
${chalk.bold.green(getType(defaultValue))}
var _chalk = require('chalk');var _chalk2 = _interopRequireDefault(_chalk);
var _jestGetType = require('jest-get-type');var _jestGetType2 = _interopRequireDefault(_jestGetType);
var _utils = require('./utils');function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const errorMessage = (option, received, defaultValue, options) => {const message = ` Option ${_chalk2.default.bold(`"${option}"`)} must be of type:
${_chalk2.default.bold.green((0, _jestGetType2.default)(defaultValue))}
but instead received:
${chalk.bold.red(getType(received))}
${_chalk2.default.bold.red((0, _jestGetType2.default)(received))}
Example:
{
${chalk.bold(`"${option}"`)}: ${chalk.bold(format(defaultValue))}
${_chalk2.default.bold(`"${option}"`)}: ${_chalk2.default.bold((0, _utils.format)(defaultValue))}
}`;
const comment = options.comment;
const name = options.title && options.title.error || ERROR;
const name = options.title && options.title.error || _utils.ERROR;
throw new ValidationError(name, message, comment);
throw new _utils.ValidationError(name, message, comment);
};
module.exports = {
ValidationError,
ValidationError: _utils.ValidationError,
errorMessage };

@@ -1,16 +0,28 @@

'use strict'; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
'use strict';
var _utils = require('./utils');
var _errors = require('./errors');
var _validate = require('./validate');var _validate2 = _interopRequireDefault(_validate);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
module.exports = {
ValidationError: require('./errors').ValidationError,
createDidYouMeanMessage: require('./utils').createDidYouMeanMessage,
format: require('./utils').format,
logValidationWarning: require('./utils').logValidationWarning,
validate: require('./validate') };
ValidationError: _errors.ValidationError,
createDidYouMeanMessage: _utils.createDidYouMeanMessage,
format: _utils.format,
logValidationWarning: _utils.logValidationWarning,
validate: _validate2.default }; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/

@@ -1,22 +0,25 @@

'use strict'; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
'use strict';
const chalk = require('chalk');
const BULLET = chalk.bold('\u25cf');
const DEPRECATION = `${BULLET} Deprecation Warning`;
const ERROR = `${BULLET} Validation Error`;
const WARNING = `${BULLET} Validation Warning`;
const format = value =>
typeof value === 'function' ?
value.toString() :
require('pretty-format')(value, { min: true });
var _chalk = require('chalk');var _chalk2 = _interopRequireDefault(_chalk);
var _prettyFormat = require('pretty-format');var _prettyFormat2 = _interopRequireDefault(_prettyFormat);
var _leven = require('leven');var _leven2 = _interopRequireDefault(_leven);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
const BULLET = _chalk2.default.bold('\u25cf'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const DEPRECATION = `${BULLET} Deprecation Warning`;const ERROR = `${BULLET} Validation Error`;const WARNING = `${BULLET} Validation Warning`;const format = value => typeof value === 'function' ? value.toString() : (0, _prettyFormat2.default)(value, { min: true });
class ValidationError extends Error {

@@ -30,4 +33,3 @@

this.name = '';
this.stack = '';
this.message = chalk.red(chalk.bold(name) + ':\n\n' + message + comment);
this.message = _chalk2.default.red(_chalk2.default.bold(name) + ':\n\n' + message + comment);
Error.captureStackTrace(this, () => {});

@@ -43,3 +45,3 @@ }}

comment = comment ? '\n\n' + comment : '\n';
console.warn(chalk.yellow(chalk.bold(name) + ':\n\n' + message + comment));
console.warn(_chalk2.default.yellow(_chalk2.default.bold(name) + ':\n\n' + message + comment));
};

@@ -51,9 +53,8 @@

{
const leven = require('leven');
const suggestion = allowedOptions.find(option => {
const steps = leven(option, unrecognized);
const steps = (0, _leven2.default)(option, unrecognized);
return steps < 3;
});
return suggestion ? `Did you mean ${chalk.bold(format(suggestion))}?` : '';
return suggestion ? `Did you mean ${_chalk2.default.bold(format(suggestion))}?` : '';
};

@@ -60,0 +61,0 @@

@@ -13,11 +13,11 @@ 'use strict';

const defaultConfig = require('./defaultConfig'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const _validate = (config, options) => {let hasDeprecationWarnings = false;for (const key in config) {if (options.deprecatedConfig && key in options.deprecatedConfig &&
var _default_config = require('./default_config');var _default_config2 = _interopRequireDefault(_default_config);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const _validate = (config, options) => {let hasDeprecationWarnings = false;for (const key in config) {if (options.deprecatedConfig && key in options.deprecatedConfig &&
typeof options.deprecate === 'function')

@@ -51,9 +51,9 @@ {

const validate = (config, options) => {
_validate(options, defaultConfig); // validate against jest-validate config
_validate(options, _default_config2.default); // validate against jest-validate config
const defaultedOptions = Object.assign(
{},
defaultConfig,
{}, _default_config2.default,
options,
{ title: Object.assign({}, defaultConfig.title, options.title) });var _validate2 =
{ title: Object.assign({}, _default_config2.default.title, options.title) });var _validate2 =

@@ -60,0 +60,0 @@

@@ -13,11 +13,11 @@ 'use strict';

const chalk = require('chalk'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/var _require = require('./utils');const format = _require.format,logValidationWarning = _require.logValidationWarning,createDidYouMeanMessage = _require.createDidYouMeanMessage,WARNING = _require.WARNING;const unknownOptionWarning = (
var _chalk = require('chalk');var _chalk2 = _interopRequireDefault(_chalk);
var _utils = require('./utils');function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
const unknownOptionWarning = (
config,

@@ -28,3 +28,3 @@ exampleConfig,

{
const didYouMean = createDidYouMeanMessage(
const didYouMean = (0, _utils.createDidYouMeanMessage)(
option,

@@ -34,3 +34,3 @@ Object.keys(exampleConfig));

const message =
` Unknown option ${chalk.bold(`"${option}"`)} with value ${chalk.bold(format(config[option]))} was found.` + (
` Unknown option ${_chalk2.default.bold(`"${option}"`)} with value ${_chalk2.default.bold((0, _utils.format)(config[option]))} was found.` + (
didYouMean && ` ${didYouMean}`) +

@@ -40,8 +40,13 @@ `\n This is probably a typing mistake. Fixing it will remove this message.`;

const comment = options.comment;
const name = options.title && options.title.warning || WARNING;
const name = options.title && options.title.warning || _utils.WARNING;
logValidationWarning(name, message, comment);
};
module.exports = {
unknownOptionWarning };
(0, _utils.logValidationWarning)(name, message, comment);
}; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/module.exports = { unknownOptionWarning };
{
"name": "jest-validate",
"version": "20.0.3",
"version": "20.1.0-alpha.1",
"repository": {

@@ -10,9 +10,8 @@ "type": "git",

"main": "build/index.js",
"browser": "build-es5/index.js",
"dependencies": {
"chalk": "^1.1.3",
"jest-matcher-utils": "^20.0.3",
"jest-get-type": "^20.1.0-alpha.1",
"leven": "^2.1.0",
"pretty-format": "^20.0.3"
"pretty-format": "^20.1.0-alpha.1"
}
}

@@ -65,3 +65,3 @@ # jest-validate

* `comment` – optional string to be rendered bellow error/warning message.
* `comment` – optional string to be rendered below error/warning message.
* `condition` – an optional function with validation condition.

@@ -88,8 +88,8 @@ * `deprecate`, `error`, `unknown` – optional functions responsible for displaying warning and error messages.

comment: ' Documentation: http://custom-docs.com',
deprecatedConfig,
exampleConfig,
deprecatedConfig,
title: {
deprecation: 'Custom Deprecation',
// leaving 'error' and 'warning' as default
}
},
});

@@ -96,0 +96,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc