Socket
Socket
Sign inDemoInstall

schema-utils

Package Overview
Dependencies
9
Maintainers
3
Versions
39
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.7 to 1.0.0

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="1.0.0"></a>
# [1.0.0](https://github.com/webpack-contrib/schema-utils/compare/v0.4.7...v1.0.0) (2018-08-07)
### Features
* **src:** add support for custom error messages ([#33](https://github.com/webpack-contrib/schema-utils/issues/33)) ([1cbe4ef](https://github.com/webpack-contrib/schema-utils/commit/1cbe4ef))
<a name="0.4.7"></a>

@@ -7,0 +17,0 @@ ## [0.4.7](https://github.com/webpack-contrib/schema-utils/compare/v0.4.6...v0.4.7) (2018-08-07)

3

package.json
{
"name": "schema-utils",
"version": "0.4.7",
"version": "1.0.0",
"description": "webpack Validation Utils",

@@ -21,2 +21,3 @@ "main": "src/index.js",

"ajv": "^6.1.0",
"ajv-errors": "^1.0.0",
"ajv-keywords": "^3.1.0"

@@ -23,0 +24,0 @@ },

@@ -30,3 +30,3 @@ [![npm][npm]][npm-url]

**schema.json**
**`schema.json`**
```js

@@ -42,3 +42,22 @@ {

#### Error Messages (Custom)
**`schema.json`**
```js
{
"type": "object",
"properties": {
"option": {
"type": [ "boolean" ]
}
},
// Overrides the default err.message for option
"errorMessage": {
"option": "should be {Boolean} (https:/github.com/org/repo#anchor)"
}
"additionalProperties": false
}
```
```js
import schema from 'path/to/schema.json'

@@ -45,0 +64,0 @@ import validateOptions from 'schema-utils'

@@ -12,3 +12,4 @@ /* eslint-disable

const Ajv = require('ajv');
const ajvKeywords = require('ajv-keywords');
const errors = require('ajv-errors');
const keywords = require('ajv-keywords');

@@ -19,7 +20,7 @@ const ValidationError = require('./ValidationError');

allErrors: true,
useDefaults: true,
errorDataPath: 'property',
jsonPointers: true,
});
ajvKeywords(ajv, ['instanceof', 'typeof']);
errors(ajv);
keywords(ajv, ['instanceof', 'typeof']);

@@ -26,0 +27,0 @@ const validateOptions = (schema, options, name) => {

/* eslint-disable
strict
strict,
no-param-reassign
*/

@@ -15,8 +16,12 @@

errors.forEach((err) => {
this.errors = errors.map((err) => {
err.dataPath = err.dataPath.replace(/\//g, '.');
return err;
});
this.errors.forEach((err) => {
this.message += `options${err.dataPath} ${err.message}\n`;
});
this.errors = errors;
Error.captureStackTrace(this, this.constructor);

@@ -23,0 +28,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