Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ajv-keywords

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv-keywords - npm Package Compare versions

Comparing version 2.0.1-beta.2 to 2.1.0

keywords/uniqueItemProperties.js

3

keywords/dotjs/patternRequired.js

@@ -10,3 +10,2 @@ 'use strict';

var $breakOnError = !it.opts.allErrors;
var $errorKeyword;
var $data = 'data' + ($dataLvl || '');

@@ -40,3 +39,3 @@ var $valid = 'valid' + $lvl;

if (it.createErrors !== false) {
out += ' { keyword: \'' + ($errorKeyword || 'patternRequired') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingPattern: \'' + ($missingPattern) + '\' } ';
out += ' { keyword: \'' + ('patternRequired') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingPattern: \'' + ($missingPattern) + '\' } ';
if (it.opts.messages !== false) {

@@ -43,0 +42,0 @@ out += ' , message: \'should have property matching pattern \\\'' + ($missingPattern) + '\\\'\' ';

@@ -10,3 +10,2 @@ 'use strict';

var $breakOnError = !it.opts.allErrors;
var $errorKeyword;
var $data = 'data' + ($dataLvl || '');

@@ -52,3 +51,3 @@ var $valid = 'valid' + $lvl;

if (it.createErrors !== false) {
out += ' { keyword: \'' + ($errorKeyword || 'switch') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { caseIndex: ' + ($caseIndex) + ' } ';
out += ' { keyword: \'' + ('switch') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { caseIndex: ' + ($caseIndex) + ' } ';
if (it.opts.messages !== false) {

@@ -93,3 +92,3 @@ out += ' , message: \'should pass "switch" keyword validation\' ';

if (it.createErrors !== false) {
out += ' { keyword: \'' + ($errorKeyword || 'switch') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { caseIndex: ' + ($caseIndex) + ' } ';
out += ' { keyword: \'' + ('switch') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { caseIndex: ' + ($caseIndex) + ' } ';
if (it.opts.messages !== false) {

@@ -96,0 +95,0 @@ out += ' , message: \'should pass "switch" keyword validation\' ';

@@ -11,2 +11,3 @@ 'use strict';

prohibited: require('./prohibited'),
uniqueItemProperties: require('./uniqueItemProperties'),
deepProperties: require('./deepProperties'),

@@ -13,0 +14,0 @@ deepRequired: require('./deepRequired'),

{
"name": "ajv-keywords",
"version": "2.0.1-beta.2",
"version": "2.1.0",
"description": "Custom JSON-Schema keywords for Ajv validator",

@@ -34,7 +34,7 @@ "main": "index.js",

"peerDependencies": {
"ajv": ">=5.0.4-beta.0"
"ajv": ">=5.0.0"
},
"devDependencies": {
"ajv": "^5.0.4-beta.0",
"ajv-pack": "^0.2.0",
"ajv": "^5.0.0",
"ajv-pack": "^0.3.0",
"chai": "^3.5.0",

@@ -41,0 +41,0 @@ "coveralls": "^2.11.9",

@@ -9,2 +9,4 @@ # ajv-keywords

[![Coverage Status](https://coveralls.io/repos/github/epoberezkin/ajv-keywords/badge.svg?branch=master)](https://coveralls.io/github/epoberezkin/ajv-keywords?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/epoberezkin/ajv-keywords.svg)](https://greenkeeper.io/)
[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)

@@ -27,2 +29,3 @@

- [deepRequired](#deeprequired)
- [uniqueItemProperties](#uniqueitemproperties)
- [regexp](#regexp)

@@ -101,3 +104,3 @@ - [formatMaximum / formatMinimum and formatExclusiveMaximum / formatExclusiveMinimum](#formatmaximum--formatminimum-and-formatexclusivemaximum--formatexclusiveminimum)

ajv.validate({ instanceof: 'Array' }, {}); // false
ajv.validate({ instanceof: ['Array', 'Function'] }, funciton(){}); // true
ajv.validate({ instanceof: ['Array', 'Function'] }, function(){}); // true
```

@@ -453,2 +456,35 @@

### `uniqueItemProperties`
The keyword allows to check that some properties in array items are unique.
This keyword applies only to arrays. If the data is not an array, the validation succeeds.
The value of this keyword must be an array of strings - property names that should have unique values accross all items.
```javascript
var schema = { uniqueItemProperties: [ "id", "name" ] };
var validData = [
{ id: 1 },
{ id: 2 },
{ id: 3 }
];
var invalidData1 = [
{ id: 1 },
{ id: 1 },
{ id: 3 }
];
var invalidData2 = [
{ id: 1, name: "taco" },
{ id: 2, name: "taco" }, // duplicate "name"
{ id: 3, name: "salsa" }
];
```
This keyword is contributed by [@blainesch](https://github.com/blainesch).
### `regexp`

@@ -624,2 +660,2 @@

[MIT](https://github.com/JSONScript/ajv-keywords/blob/master/LICENSE)
[MIT](https://github.com/epoberezkin/ajv-keywords/blob/master/LICENSE)
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc