aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ajv-keywords
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/ajv-keywords
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
downloadwallet-core-bbff7403fbf46f9ad92240ac213df8d30ef31b64.tar.xz
update packages
Diffstat (limited to 'node_modules/ajv-keywords')
-rw-r--r--node_modules/ajv-keywords/README.md95
-rw-r--r--node_modules/ajv-keywords/keywords/if.js21
-rw-r--r--node_modules/ajv-keywords/keywords/index.js4
-rw-r--r--node_modules/ajv-keywords/keywords/instanceof.js4
-rw-r--r--node_modules/ajv-keywords/package.json10
5 files changed, 72 insertions, 62 deletions
diff --git a/node_modules/ajv-keywords/README.md b/node_modules/ajv-keywords/README.md
index 0eb497175..6b630be1e 100644
--- a/node_modules/ajv-keywords/README.md
+++ b/node_modules/ajv-keywords/README.md
@@ -3,7 +3,7 @@
Custom JSON-Schema keywords for [Ajv](https://github.com/epoberezkin/ajv) validator
[![Build Status](https://travis-ci.org/epoberezkin/ajv-keywords.svg?branch=master)](https://travis-ci.org/epoberezkin/ajv-keywords)
-[![npm version](https://badge.fury.io/js/ajv-keywords.svg)](https://www.npmjs.com/package/ajv-keywords)
+[![npm](https://img.shields.io/npm/v/ajv-keywords.svg)](https://www.npmjs.com/package/ajv-keywords)
[![npm downloads](https://img.shields.io/npm/dm/ajv-keywords.svg)](https://www.npmjs.com/package/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/)
@@ -18,7 +18,6 @@ Custom JSON-Schema keywords for [Ajv](https://github.com/epoberezkin/ajv) valida
- [typeof](#typeof)
- [instanceof](#instanceof)
- [range and exclusiveRange](#range-and-exclusiverange)
- - [if/then/else](#ifthenelse)
- [switch](#switch)
- [select/selectCases/selectDefault](#selectselectcasesselectdefault) (BETA)
- [patternRequired](#patternrequired)
@@ -29,6 +28,7 @@ Custom JSON-Schema keywords for [Ajv](https://github.com/epoberezkin/ajv) valida
- [regexp](#regexp)
- [formatMaximum / formatMinimum and formatExclusiveMaximum / formatExclusiveMinimum](#formatmaximum--formatminimum-and-formatexclusivemaximum--formatexclusiveminimum)
- [dynamicDefaults](#dynamicdefaults)
+ - [transform](#transform)
- [License](#license)
@@ -92,7 +92,7 @@ ajv.validate({ typeof: ['undefined', 'object'] }, null); // true
Based on JavaScript `instanceof` operation.
-The value of the keyword should be a string (`"Object"`, `"Array"`, `"Function"`, `"Number"`, `"String"`, `"Date"`, `"RegExp"` or `"Buffer"`) or array of strings.
+The value of the keyword should be a string (`"Object"`, `"Array"`, `"Function"`, `"Number"`, `"String"`, `"Date"`, `"RegExp"`, `"Promise"` or `"Buffer"`) or array of strings.
To pass validation the result of `data instanceof ...` operation on the value should be true:
@@ -139,37 +139,6 @@ ajv.validate(schema, 3); // false
```
-### `if`/`then`/`else`
-
-These keywords allow to implement conditional validation. Their values should be valid JSON-schemas.
-
-If the data is valid according to the sub-schema in `if` keyword, then the result is equal to the result of data validation against the sub-schema in `then` keyword, otherwise - in `else` keyword (if `else` is absent, the validation succeeds).
-
-```javascript
-require('ajv-keywords')(ajv, 'if');
-
-var schema = {
- type: 'array',
- items: {
- type: 'integer',
- minimum: 1,
- if: { maximum: 10 },
- then: { multipleOf: 2 },
- else: { multipleOf: 5 }
- }
-};
-
-var validItems = [ 2, 4, 6, 8, 10, 15, 20, 25 ]; // etc.
-
-var invalidItems = [ 1, 3, 5, 11, 12 ]; // etc.
-
-ajv.validate(schema, validItems); // true
-ajv.validate(schema, invalidItems); // false
-```
-
-This keyword is [proposed](https://github.com/json-schema-org/json-schema-spec/issues/180) for the future version of JSON-Schema standard.
-
-
### `switch`
This keyword allows to perform advanced conditional validation.
@@ -650,6 +619,64 @@ var schema = {
};
```
+### `transform`
+
+This keyword allows a string to be modified before validation.
+
+These keywords apply only to strings. If the data is not a string, the transform is skipped.
+
+There are limitation due to how ajv is written:
+- a stand alone string cannot be transformed. ie `data = 'a'; ajv.validate(schema, data);`
+- currently cannot work with `ajv-pack`
+
+**Supported options:**
+- `trim`: remove whitespace from start and end
+- `trimLeft`: remove whitespace from start
+- `trimRight`: remove whitespace from end
+- `toLowerCase`: case string to all lower case
+- `toUpperCase`: case string to all upper case
+- `toEnumCase`: case string to match case in schema
+
+Options are applied in the order they are listed.
+
+Note: `toEnumCase` requires that all allowed values are unique when case insensitive.
+
+**Example: multiple options**
+```javascript
+require('ajv-keywords')(ajv, ['transform']);
+
+var schema = {
+ type: 'array',
+ items: {
+ type:'string',
+ transform:['trim','lowercase']
+ }
+};
+
+var data = [' MixCase '];
+avj.validate(schema, data);
+console.log(data); // ['mixcase']
+
+```
+
+**Example: `enumcase`**
+```javascript
+require('ajv-keywords')(ajv, ['transform']);
+
+var schema = {
+ type: 'array',
+ items: {
+ type:'string',
+ transform:['trim','enumcase'],
+ enum:['pH']
+ }
+};
+
+var data = ['ph',' Ph','PH','pH '];
+avj.validate(schema, data);
+console.log(data); // ['pH','pH','pH','pH']
+```
+
## License
diff --git a/node_modules/ajv-keywords/keywords/if.js b/node_modules/ajv-keywords/keywords/if.js
deleted file mode 100644
index 8a8fc95ee..000000000
--- a/node_modules/ajv-keywords/keywords/if.js
+++ /dev/null
@@ -1,21 +0,0 @@
-'use strict';
-
-module.exports = function defFunc(ajv) {
- if (!ajv.RULES.keywords.switch) require('./switch')(ajv);
-
- defFunc.definition = {
- macro: function (schema, parentSchema) {
- if (parentSchema.then === undefined)
- throw new Error('keyword "then" is absent');
- var cases = [ { 'if': schema, 'then': parentSchema.then } ];
- if (parentSchema.else !== undefined)
- cases[1] = { 'then': parentSchema.else };
- return { switch: cases };
- }
- };
-
- ajv.addKeyword('if', defFunc.definition);
- ajv.addKeyword('then');
- ajv.addKeyword('else');
- return ajv;
-};
diff --git a/node_modules/ajv-keywords/keywords/index.js b/node_modules/ajv-keywords/keywords/index.js
index 06b68b776..618ed0214 100644
--- a/node_modules/ajv-keywords/keywords/index.js
+++ b/node_modules/ajv-keywords/keywords/index.js
@@ -6,7 +6,6 @@ module.exports = {
regexp: require('./regexp'),
'typeof': require('./typeof'),
dynamicDefaults: require('./dynamicDefaults'),
- 'if': require('./if'),
prohibited: require('./prohibited'),
uniqueItemProperties: require('./uniqueItemProperties'),
deepProperties: require('./deepProperties'),
@@ -15,5 +14,6 @@ module.exports = {
formatMaximum: require('./formatMaximum'),
patternRequired: require('./patternRequired'),
'switch': require('./switch'),
- select: require('./select')
+ select: require('./select'),
+ transform: require('./transform')
};
diff --git a/node_modules/ajv-keywords/keywords/instanceof.js b/node_modules/ajv-keywords/keywords/instanceof.js
index d02906032..ea88f5ca3 100644
--- a/node_modules/ajv-keywords/keywords/instanceof.js
+++ b/node_modules/ajv-keywords/keywords/instanceof.js
@@ -15,6 +15,10 @@ module.exports = function defFunc(ajv) {
if (typeof Buffer != 'undefined')
CONSTRUCTORS.Buffer = Buffer;
+ /* istanbul ignore else */
+ if (typeof Promise != 'undefined')
+ CONSTRUCTORS.Promise = Promise;
+
defFunc.definition = {
compile: function (schema) {
if (typeof schema == 'string') {
diff --git a/node_modules/ajv-keywords/package.json b/node_modules/ajv-keywords/package.json
index d8e5afd7e..2f42ce370 100644
--- a/node_modules/ajv-keywords/package.json
+++ b/node_modules/ajv-keywords/package.json
@@ -1,6 +1,6 @@
{
"name": "ajv-keywords",
- "version": "2.1.1",
+ "version": "3.2.0",
"description": "Custom JSON-Schema keywords for Ajv validator",
"main": "index.js",
"scripts": {
@@ -31,10 +31,10 @@
},
"homepage": "https://github.com/epoberezkin/ajv-keywords#readme",
"peerDependencies": {
- "ajv": "^5.0.0"
+ "ajv": "^6.0.0"
},
"devDependencies": {
- "ajv": "^5.0.0",
+ "ajv": "^6.0.0",
"ajv-pack": "^0.3.0",
"chai": "^4.0.2",
"coveralls": "^3.0.0",
@@ -43,8 +43,8 @@
"glob": "^7.1.1",
"istanbul": "^0.4.3",
"js-beautify": "^1.7.4",
- "json-schema-test": "^1.3.0",
- "mocha": "^4.0.0",
+ "json-schema-test": "^2.0.0",
+ "mocha": "^5.0.0",
"pre-commit": "^1.1.3",
"uuid": "^3.0.1"
}