progress on migrating to heex templates and font-icons
This commit is contained in:
parent
d43daafdb7
commit
3eff955672
21793 changed files with 2161968 additions and 16895 deletions
assets_old/node_modules/ajv-keywords
LICENSEREADME.mdajv-keywords.d.tsindex.js
keywords
_formatLimit.js_util.jsallRequired.jsanyRequired.jsdeepProperties.jsdeepRequired.js
package.jsondot
dotjs
dynamicDefaults.jsformatMaximum.jsformatMinimum.jsindex.jsinstanceof.jsoneRequired.jspatternRequired.jsprohibited.jsrange.jsregexp.jsselect.jsswitch.jstransform.jstypeof.jsuniqueItemProperties.js
21
assets_old/node_modules/ajv-keywords/LICENSE
generated
vendored
Normal file
21
assets_old/node_modules/ajv-keywords/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Evgeny Poberezkin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
836
assets_old/node_modules/ajv-keywords/README.md
generated
vendored
Normal file
836
assets_old/node_modules/ajv-keywords/README.md
generated
vendored
Normal file
|
@ -0,0 +1,836 @@
|
|||
# ajv-keywords
|
||||
|
||||
Custom JSON-Schema keywords for [Ajv](https://github.com/epoberezkin/ajv) validator
|
||||
|
||||
[](https://travis-ci.org/ajv-validator/ajv-keywords)
|
||||
[](https://www.npmjs.com/package/ajv-keywords)
|
||||
[](https://www.npmjs.com/package/ajv-keywords)
|
||||
[](https://coveralls.io/github/ajv-validator/ajv-keywords?branch=master)
|
||||
[](https://app.dependabot.com/accounts/ajv-validator/repos/60477053)
|
||||
[](https://gitter.im/ajv-validator/ajv)
|
||||
|
||||
|
||||
## Contents
|
||||
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [Keywords](#keywords)
|
||||
- [Types](#types)
|
||||
- [typeof](#typeof)
|
||||
- [instanceof](#instanceof)
|
||||
- [Keywords for numbers](#keywords-for-numbers)
|
||||
- [range and exclusiveRange](#range-and-exclusiverange)
|
||||
- [Keywords for strings](#keywords-for-strings)
|
||||
- [regexp](#regexp)
|
||||
- [formatMaximum / formatMinimum and formatExclusiveMaximum / formatExclusiveMinimum](#formatmaximum--formatminimum-and-formatexclusivemaximum--formatexclusiveminimum)
|
||||
- [transform](#transform)<sup>\*</sup>
|
||||
- [Keywords for arrays](#keywords-for-arrays)
|
||||
- [uniqueItemProperties](#uniqueitemproperties)
|
||||
- [Keywords for objects](#keywords-for-objects)
|
||||
- [allRequired](#allrequired)
|
||||
- [anyRequired](#anyrequired)
|
||||
- [oneRequired](#onerequired)
|
||||
- [patternRequired](#patternrequired)
|
||||
- [prohibited](#prohibited)
|
||||
- [deepProperties](#deepproperties)
|
||||
- [deepRequired](#deeprequired)
|
||||
- [Compound keywords](#compound-keywords)
|
||||
- [switch](#switch) (deprecated)
|
||||
- [select/selectCases/selectDefault](#selectselectcasesselectdefault) (BETA)
|
||||
- [Keywords for all types](#keywords-for-all-types)
|
||||
- [dynamicDefaults](#dynamicdefaults)<sup>\*</sup>
|
||||
- [Security contact](#security-contact)
|
||||
- [Open-source software support](#open-source-software-support)
|
||||
- [License](#license)
|
||||
|
||||
<sup>\*</sup> - keywords that modify data
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install ajv-keywords
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
To add all available keywords:
|
||||
|
||||
```javascript
|
||||
var Ajv = require('ajv');
|
||||
var ajv = new Ajv;
|
||||
require('ajv-keywords')(ajv);
|
||||
|
||||
ajv.validate({ instanceof: 'RegExp' }, /.*/); // true
|
||||
ajv.validate({ instanceof: 'RegExp' }, '.*'); // false
|
||||
```
|
||||
|
||||
To add a single keyword:
|
||||
|
||||
```javascript
|
||||
require('ajv-keywords')(ajv, 'instanceof');
|
||||
```
|
||||
|
||||
To add multiple keywords:
|
||||
|
||||
```javascript
|
||||
require('ajv-keywords')(ajv, ['typeof', 'instanceof']);
|
||||
```
|
||||
|
||||
To add a single keyword in browser (to avoid adding unused code):
|
||||
|
||||
```javascript
|
||||
require('ajv-keywords/keywords/instanceof')(ajv);
|
||||
```
|
||||
|
||||
|
||||
## Keywords
|
||||
|
||||
### Types
|
||||
|
||||
#### `typeof`
|
||||
|
||||
Based on JavaScript `typeof` operation.
|
||||
|
||||
The value of the keyword should be a string (`"undefined"`, `"string"`, `"number"`, `"object"`, `"function"`, `"boolean"` or `"symbol"`) or array of strings.
|
||||
|
||||
To pass validation the result of `typeof` operation on the value should be equal to the string (or one of the strings in the array).
|
||||
|
||||
```
|
||||
ajv.validate({ typeof: 'undefined' }, undefined); // true
|
||||
ajv.validate({ typeof: 'undefined' }, null); // false
|
||||
ajv.validate({ typeof: ['undefined', 'object'] }, null); // true
|
||||
```
|
||||
|
||||
|
||||
#### `instanceof`
|
||||
|
||||
Based on JavaScript `instanceof` operation.
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
ajv.validate({ instanceof: 'Array' }, []); // true
|
||||
ajv.validate({ instanceof: 'Array' }, {}); // false
|
||||
ajv.validate({ instanceof: ['Array', 'Function'] }, function(){}); // true
|
||||
```
|
||||
|
||||
You can add your own constructor function to be recognised by this keyword:
|
||||
|
||||
```javascript
|
||||
function MyClass() {}
|
||||
var instanceofDefinition = require('ajv-keywords').get('instanceof').definition;
|
||||
// or require('ajv-keywords/keywords/instanceof').definition;
|
||||
instanceofDefinition.CONSTRUCTORS.MyClass = MyClass;
|
||||
|
||||
ajv.validate({ instanceof: 'MyClass' }, new MyClass); // true
|
||||
```
|
||||
|
||||
|
||||
### Keywords for numbers
|
||||
|
||||
#### `range` and `exclusiveRange`
|
||||
|
||||
Syntax sugar for the combination of minimum and maximum keywords, also fails schema compilation if there are no numbers in the range.
|
||||
|
||||
The value of this keyword must be the array consisting of two numbers, the second must be greater or equal than the first one.
|
||||
|
||||
If the validated value is not a number the validation passes, otherwise to pass validation the value should be greater (or equal) than the first number and smaller (or equal) than the second number in the array. If `exclusiveRange` keyword is present in the same schema and its value is true, the validated value must not be equal to the range boundaries.
|
||||
|
||||
```javascript
|
||||
var schema = { range: [1, 3] };
|
||||
ajv.validate(schema, 1); // true
|
||||
ajv.validate(schema, 2); // true
|
||||
ajv.validate(schema, 3); // true
|
||||
ajv.validate(schema, 0.99); // false
|
||||
ajv.validate(schema, 3.01); // false
|
||||
|
||||
var schema = { range: [1, 3], exclusiveRange: true };
|
||||
ajv.validate(schema, 1.01); // true
|
||||
ajv.validate(schema, 2); // true
|
||||
ajv.validate(schema, 2.99); // true
|
||||
ajv.validate(schema, 1); // false
|
||||
ajv.validate(schema, 3); // false
|
||||
```
|
||||
|
||||
|
||||
### Keywords for strings
|
||||
|
||||
#### `regexp`
|
||||
|
||||
This keyword allows to use regular expressions with flags in schemas (the standard `pattern` keyword does not support flags).
|
||||
|
||||
This keyword applies only to strings. If the data is not a string, the validation succeeds.
|
||||
|
||||
The value of this keyword can be either a string (the result of `regexp.toString()`) or an object with the properties `pattern` and `flags` (the same strings that should be passed to RegExp constructor).
|
||||
|
||||
```javascript
|
||||
var schema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
foo: { regexp: '/foo/i' },
|
||||
bar: { regexp: { pattern: 'bar', flags: 'i' } }
|
||||
}
|
||||
};
|
||||
|
||||
var validData = {
|
||||
foo: 'Food',
|
||||
bar: 'Barmen'
|
||||
};
|
||||
|
||||
var invalidData = {
|
||||
foo: 'fog',
|
||||
bar: 'bad'
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
#### `formatMaximum` / `formatMinimum` and `formatExclusiveMaximum` / `formatExclusiveMinimum`
|
||||
|
||||
These keywords allow to define minimum/maximum constraints when the format keyword defines ordering.
|
||||
|
||||
These keywords apply only to strings. If the data is not a string, the validation succeeds.
|
||||
|
||||
The value of keyword `formatMaximum` (`formatMinimum`) should be a string. This value is the maximum (minimum) allowed value for the data to be valid as determined by `format` keyword. If `format` is not present schema compilation will throw exception.
|
||||
|
||||
When this keyword is added, it defines comparison rules for formats `"date"`, `"time"` and `"date-time"`. Custom formats also can have comparison rules. See [addFormat](https://github.com/epoberezkin/ajv#api-addformat) method.
|
||||
|
||||
The value of keyword `formatExclusiveMaximum` (`formatExclusiveMinimum`) should be a boolean value. These keyword cannot be used without `formatMaximum` (`formatMinimum`). If this keyword value is equal to `true`, the data to be valid should not be equal to the value in `formatMaximum` (`formatMinimum`) keyword.
|
||||
|
||||
```javascript
|
||||
require('ajv-keywords')(ajv, ['formatMinimum', 'formatMaximum']);
|
||||
|
||||
var schema = {
|
||||
format: 'date',
|
||||
formatMinimum: '2016-02-06',
|
||||
formatMaximum: '2016-12-27',
|
||||
formatExclusiveMaximum: true
|
||||
}
|
||||
|
||||
var validDataList = ['2016-02-06', '2016-12-26', 1];
|
||||
|
||||
var invalidDataList = ['2016-02-05', '2016-12-27', 'abc'];
|
||||
```
|
||||
|
||||
|
||||
#### `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','toLowerCase']
|
||||
}
|
||||
};
|
||||
|
||||
var data = [' MixCase '];
|
||||
ajv.validate(schema, data);
|
||||
console.log(data); // ['mixcase']
|
||||
|
||||
```
|
||||
|
||||
**Example: `enumcase`**
|
||||
```javascript
|
||||
require('ajv-keywords')(ajv, ['transform']);
|
||||
|
||||
var schema = {
|
||||
type: 'array',
|
||||
items: {
|
||||
type:'string',
|
||||
transform:['trim','toEnumCase'],
|
||||
enum:['pH']
|
||||
}
|
||||
};
|
||||
|
||||
var data = ['ph',' Ph','PH','pH '];
|
||||
ajv.validate(schema, data);
|
||||
console.log(data); // ['pH','pH','pH','pH']
|
||||
```
|
||||
|
||||
|
||||
### Keywords for arrays
|
||||
|
||||
#### `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 across all items.
|
||||
|
||||
```javascript
|
||||
var schema = { uniqueItemProperties: [ "id", "name" ] };
|
||||
|
||||
var validData = [
|
||||
{ id: 1 },
|
||||
{ id: 2 },
|
||||
{ id: 3 }
|
||||
];
|
||||
|
||||
var invalidData1 = [
|
||||
{ id: 1 },
|
||||
{ id: 1 }, // duplicate "id"
|
||||
{ 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).
|
||||
|
||||
|
||||
### Keywords for objects
|
||||
|
||||
#### `allRequired`
|
||||
|
||||
This keyword allows to require the presence of all properties used in `properties` keyword in the same schema object.
|
||||
|
||||
This keyword applies only to objects. If the data is not an object, the validation succeeds.
|
||||
|
||||
The value of this keyword must be boolean.
|
||||
|
||||
If the value of the keyword is `false`, the validation succeeds.
|
||||
|
||||
If the value of the keyword is `true`, the validation succeeds if the data contains all properties defined in `properties` keyword (in the same schema object).
|
||||
|
||||
If the `properties` keyword is not present in the same schema object, schema compilation will throw exception.
|
||||
|
||||
```javascript
|
||||
var schema = {
|
||||
properties: {
|
||||
foo: {type: 'number'},
|
||||
bar: {type: 'number'}
|
||||
}
|
||||
allRequired: true
|
||||
};
|
||||
|
||||
var validData = { foo: 1, bar: 2 };
|
||||
var alsoValidData = { foo: 1, bar: 2, baz: 3 };
|
||||
|
||||
var invalidDataList = [ {}, { foo: 1 }, { bar: 2 } ];
|
||||
```
|
||||
|
||||
|
||||
#### `anyRequired`
|
||||
|
||||
This keyword allows to require the presence of any (at least one) property from the list.
|
||||
|
||||
This keyword applies only to objects. If the data is not an object, the validation succeeds.
|
||||
|
||||
The value of this keyword must be an array of strings, each string being a property name. For data object to be valid at least one of the properties in this array should be present in the object.
|
||||
|
||||
```javascript
|
||||
var schema = {
|
||||
anyRequired: ['foo', 'bar']
|
||||
};
|
||||
|
||||
var validData = { foo: 1 };
|
||||
var alsoValidData = { foo: 1, bar: 2 };
|
||||
|
||||
var invalidDataList = [ {}, { baz: 3 } ];
|
||||
```
|
||||
|
||||
|
||||
#### `oneRequired`
|
||||
|
||||
This keyword allows to require the presence of only one property from the list.
|
||||
|
||||
This keyword applies only to objects. If the data is not an object, the validation succeeds.
|
||||
|
||||
The value of this keyword must be an array of strings, each string being a property name. For data object to be valid exactly one of the properties in this array should be present in the object.
|
||||
|
||||
```javascript
|
||||
var schema = {
|
||||
oneRequired: ['foo', 'bar']
|
||||
};
|
||||
|
||||
var validData = { foo: 1 };
|
||||
var alsoValidData = { bar: 2, baz: 3 };
|
||||
|
||||
var invalidDataList = [ {}, { baz: 3 }, { foo: 1, bar: 2 } ];
|
||||
```
|
||||
|
||||
|
||||
#### `patternRequired`
|
||||
|
||||
This keyword allows to require the presence of properties that match some pattern(s).
|
||||
|
||||
This keyword applies only to objects. If the data is not an object, the validation succeeds.
|
||||
|
||||
The value of this keyword should be an array of strings, each string being a regular expression. For data object to be valid each regular expression in this array should match at least one property name in the data object.
|
||||
|
||||
If the array contains multiple regular expressions, more than one expression can match the same property name.
|
||||
|
||||
```javascript
|
||||
var schema = { patternRequired: [ 'f.*o', 'b.*r' ] };
|
||||
|
||||
var validData = { foo: 1, bar: 2 };
|
||||
var alsoValidData = { foobar: 3 };
|
||||
|
||||
var invalidDataList = [ {}, { foo: 1 }, { bar: 2 } ];
|
||||
```
|
||||
|
||||
|
||||
#### `prohibited`
|
||||
|
||||
This keyword allows to prohibit that any of the properties in the list is present in the object.
|
||||
|
||||
This keyword applies only to objects. If the data is not an object, the validation succeeds.
|
||||
|
||||
The value of this keyword should be an array of strings, each string being a property name. For data object to be valid none of the properties in this array should be present in the object.
|
||||
|
||||
```
|
||||
var schema = { prohibited: ['foo', 'bar']};
|
||||
|
||||
var validData = { baz: 1 };
|
||||
var alsoValidData = {};
|
||||
|
||||
var invalidDataList = [
|
||||
{ foo: 1 },
|
||||
{ bar: 2 },
|
||||
{ foo: 1, bar: 2}
|
||||
];
|
||||
```
|
||||
|
||||
__Please note__: `{prohibited: ['foo', 'bar']}` is equivalent to `{not: {anyRequired: ['foo', 'bar']}}` (i.e. it has the same validation result for any data).
|
||||
|
||||
|
||||
#### `deepProperties`
|
||||
|
||||
This keyword allows to validate deep properties (identified by JSON pointers).
|
||||
|
||||
This keyword applies only to objects. If the data is not an object, the validation succeeds.
|
||||
|
||||
The value should be an object, where keys are JSON pointers to the data, starting from the current position in data, and the values are JSON schemas. For data object to be valid the value of each JSON pointer should be valid according to the corresponding schema.
|
||||
|
||||
```javascript
|
||||
var schema = {
|
||||
type: 'object',
|
||||
deepProperties: {
|
||||
"/users/1/role": { "enum": ["admin"] }
|
||||
}
|
||||
};
|
||||
|
||||
var validData = {
|
||||
users: [
|
||||
{},
|
||||
{
|
||||
id: 123,
|
||||
role: 'admin'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var alsoValidData = {
|
||||
users: {
|
||||
"1": {
|
||||
id: 123,
|
||||
role: 'admin'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var invalidData = {
|
||||
users: [
|
||||
{},
|
||||
{
|
||||
id: 123,
|
||||
role: 'user'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var alsoInvalidData = {
|
||||
users: {
|
||||
"1": {
|
||||
id: 123,
|
||||
role: 'user'
|
||||
}
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
#### `deepRequired`
|
||||
|
||||
This keyword allows to check that some deep properties (identified by JSON pointers) are available.
|
||||
|
||||
This keyword applies only to objects. If the data is not an object, the validation succeeds.
|
||||
|
||||
The value should be an array of JSON pointers to the data, starting from the current position in data. For data object to be valid each JSON pointer should be some existing part of the data.
|
||||
|
||||
```javascript
|
||||
var schema = {
|
||||
type: 'object',
|
||||
deepRequired: ["/users/1/role"]
|
||||
};
|
||||
|
||||
var validData = {
|
||||
users: [
|
||||
{},
|
||||
{
|
||||
id: 123,
|
||||
role: 'admin'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var invalidData = {
|
||||
users: [
|
||||
{},
|
||||
{
|
||||
id: 123
|
||||
}
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
See [json-schema-org/json-schema-spec#203](https://github.com/json-schema-org/json-schema-spec/issues/203#issue-197211916) for an example of the equivalent schema without `deepRequired` keyword.
|
||||
|
||||
|
||||
### Compound keywords
|
||||
|
||||
#### `switch` (deprecated)
|
||||
|
||||
__Please note__: this keyword is provided to preserve backward compatibility with previous versions of Ajv. It is strongly recommended to use `if`/`then`/`else` keywords instead, as they have been added to the draft-07 of JSON Schema specification.
|
||||
|
||||
This keyword allows to perform advanced conditional validation.
|
||||
|
||||
The value of the keyword is the array of if/then clauses. Each clause is the object with the following properties:
|
||||
|
||||
- `if` (optional) - the value is JSON-schema
|
||||
- `then` (required) - the value is JSON-schema or boolean
|
||||
- `continue` (optional) - the value is boolean
|
||||
|
||||
The validation process is dynamic; all clauses are executed sequentially in the following way:
|
||||
|
||||
1. `if`:
|
||||
1. `if` property is JSON-schema according to which the data is:
|
||||
1. valid => go to step 2.
|
||||
2. invalid => go to the NEXT clause, if this was the last clause the validation of `switch` SUCCEEDS.
|
||||
2. `if` property is absent => go to step 2.
|
||||
2. `then`:
|
||||
1. `then` property is `true` or it is JSON-schema according to which the data is valid => go to step 3.
|
||||
2. `then` property is `false` or it is JSON-schema according to which the data is invalid => the validation of `switch` FAILS.
|
||||
3. `continue`:
|
||||
1. `continue` property is `true` => go to the NEXT clause, if this was the last clause the validation of `switch` SUCCEEDS.
|
||||
2. `continue` property is `false` or absent => validation of `switch` SUCCEEDS.
|
||||
|
||||
```javascript
|
||||
require('ajv-keywords')(ajv, 'switch');
|
||||
|
||||
var schema = {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'integer',
|
||||
'switch': [
|
||||
{ if: { not: { minimum: 1 } }, then: false },
|
||||
{ if: { maximum: 10 }, then: true },
|
||||
{ if: { maximum: 100 }, then: { multipleOf: 10 } },
|
||||
{ if: { maximum: 1000 }, then: { multipleOf: 100 } },
|
||||
{ then: false }
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
var validItems = [1, 5, 10, 20, 50, 100, 200, 500, 1000];
|
||||
|
||||
var invalidItems = [1, 0, 2000, 11, 57, 123, 'foo'];
|
||||
```
|
||||
|
||||
The above schema is equivalent to (for example):
|
||||
|
||||
```javascript
|
||||
{
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'integer',
|
||||
if: { minimum: 1, maximum: 10 },
|
||||
then: true,
|
||||
else: {
|
||||
if: { maximum: 100 },
|
||||
then: { multipleOf: 10 },
|
||||
else: {
|
||||
if: { maximum: 1000 },
|
||||
then: { multipleOf: 100 },
|
||||
else: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### `select`/`selectCases`/`selectDefault`
|
||||
|
||||
These keywords allow to choose the schema to validate the data based on the value of some property in the validated data.
|
||||
|
||||
These keywords must be present in the same schema object (`selectDefault` is optional).
|
||||
|
||||
The value of `select` keyword should be a [$data reference](https://github.com/epoberezkin/ajv/tree/5.0.2-beta.0#data-reference) that points to any primitive JSON type (string, number, boolean or null) in the data that is validated. You can also use a constant of primitive type as the value of this keyword (e.g., for debugging purposes).
|
||||
|
||||
The value of `selectCases` keyword must be an object where each property name is a possible string representation of the value of `select` keyword and each property value is a corresponding schema (from draft-06 it can be boolean) that must be used to validate the data.
|
||||
|
||||
The value of `selectDefault` keyword is a schema (from draft-06 it can be boolean) that must be used to validate the data in case `selectCases` has no key equal to the stringified value of `select` keyword.
|
||||
|
||||
The validation succeeds in one of the following cases:
|
||||
- the validation of data using selected schema succeeds,
|
||||
- none of the schemas is selected for validation,
|
||||
- the value of select is undefined (no property in the data that the data reference points to).
|
||||
|
||||
If `select` value (in data) is not a primitive type the validation fails.
|
||||
|
||||
__Please note__: these keywords require Ajv `$data` option to support [$data reference](https://github.com/epoberezkin/ajv/tree/5.0.2-beta.0#data-reference).
|
||||
|
||||
|
||||
```javascript
|
||||
require('ajv-keywords')(ajv, 'select');
|
||||
|
||||
var schema = {
|
||||
type: object,
|
||||
required: ['kind'],
|
||||
properties: {
|
||||
kind: { type: 'string' }
|
||||
},
|
||||
select: { $data: '0/kind' },
|
||||
selectCases: {
|
||||
foo: {
|
||||
required: ['foo'],
|
||||
properties: {
|
||||
kind: {},
|
||||
foo: { type: 'string' }
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
bar: {
|
||||
required: ['bar'],
|
||||
properties: {
|
||||
kind: {},
|
||||
bar: { type: 'number' }
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
selectDefault: {
|
||||
propertyNames: {
|
||||
not: { enum: ['foo', 'bar'] }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var validDataList = [
|
||||
{ kind: 'foo', foo: 'any' },
|
||||
{ kind: 'bar', bar: 1 },
|
||||
{ kind: 'anything_else', not_bar_or_foo: 'any value' }
|
||||
];
|
||||
|
||||
var invalidDataList = [
|
||||
{ kind: 'foo' }, // no propery foo
|
||||
{ kind: 'bar' }, // no propery bar
|
||||
{ kind: 'foo', foo: 'any', another: 'any value' }, // additional property
|
||||
{ kind: 'bar', bar: 1, another: 'any value' }, // additional property
|
||||
{ kind: 'anything_else', foo: 'any' } // property foo not allowed
|
||||
{ kind: 'anything_else', bar: 1 } // property bar not allowed
|
||||
];
|
||||
```
|
||||
|
||||
__Please note__: the current implementation is BETA. It does not allow using relative URIs in $ref keywords in schemas in `selectCases` and `selectDefault` that point outside of these schemas. The workaround is to use absolute URIs (that can point to any (sub-)schema added to Ajv, including those inside the current root schema where `select` is used). See [tests](https://github.com/epoberezkin/ajv-keywords/blob/v2.0.0/spec/tests/select.json#L314).
|
||||
|
||||
|
||||
### Keywords for all types
|
||||
|
||||
#### `dynamicDefaults`
|
||||
|
||||
This keyword allows to assign dynamic defaults to properties, such as timestamps, unique IDs etc.
|
||||
|
||||
This keyword only works if `useDefaults` options is used and not inside `anyOf` keywords etc., in the same way as [default keyword treated by Ajv](https://github.com/epoberezkin/ajv#assigning-defaults).
|
||||
|
||||
The keyword should be added on the object level. Its value should be an object with each property corresponding to a property name, in the same way as in standard `properties` keyword. The value of each property can be:
|
||||
|
||||
- an identifier of default function (a string)
|
||||
- an object with properties `func` (an identifier) and `args` (an object with parameters that will be passed to this function during schema compilation - see examples).
|
||||
|
||||
The properties used in `dynamicDefaults` should not be added to `required` keyword (or validation will fail), because unlike `default` this keyword is processed after validation.
|
||||
|
||||
There are several predefined dynamic default functions:
|
||||
|
||||
- `"timestamp"` - current timestamp in milliseconds
|
||||
- `"datetime"` - current date and time as string (ISO, valid according to `date-time` format)
|
||||
- `"date"` - current date as string (ISO, valid according to `date` format)
|
||||
- `"time"` - current time as string (ISO, valid according to `time` format)
|
||||
- `"random"` - pseudo-random number in [0, 1) interval
|
||||
- `"randomint"` - pseudo-random integer number. If string is used as a property value, the function will randomly return 0 or 1. If object `{ func: 'randomint', args: { max: N } }` is used then the default will be an integer number in [0, N) interval.
|
||||
- `"seq"` - sequential integer number starting from 0. If string is used as a property value, the default sequence will be used. If object `{ func: 'seq', args: { name: 'foo'} }` is used then the sequence with name `"foo"` will be used. Sequences are global, even if different ajv instances are used.
|
||||
|
||||
```javascript
|
||||
var schema = {
|
||||
type: 'object',
|
||||
dynamicDefaults: {
|
||||
ts: 'datetime',
|
||||
r: { func: 'randomint', args: { max: 100 } },
|
||||
id: { func: 'seq', args: { name: 'id' } }
|
||||
},
|
||||
properties: {
|
||||
ts: {
|
||||
type: 'string',
|
||||
format: 'date-time'
|
||||
},
|
||||
r: {
|
||||
type: 'integer',
|
||||
minimum: 0,
|
||||
exclusiveMaximum: 100
|
||||
},
|
||||
id: {
|
||||
type: 'integer',
|
||||
minimum: 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var data = {};
|
||||
ajv.validate(data); // true
|
||||
data; // { ts: '2016-12-01T22:07:28.829Z', r: 25, id: 0 }
|
||||
|
||||
var data1 = {};
|
||||
ajv.validate(data1); // true
|
||||
data1; // { ts: '2016-12-01T22:07:29.832Z', r: 68, id: 1 }
|
||||
|
||||
ajv.validate(data1); // true
|
||||
data1; // didn't change, as all properties were defined
|
||||
```
|
||||
|
||||
When using the `useDefaults` option value `"empty"`, properties and items equal to `null` or `""` (empty string) will be considered missing and assigned defaults. Use the `allOf` [compound keyword](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#compound-keywords) to execute `dynamicDefaults` before validation.
|
||||
|
||||
```javascript
|
||||
var schema = {
|
||||
allOf: [
|
||||
{
|
||||
dynamicDefaults: {
|
||||
ts: 'datetime',
|
||||
r: { func: 'randomint', args: { min: 5, max: 100 } },
|
||||
id: { func: 'seq', args: { name: 'id' } }
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
ts: {
|
||||
type: 'string'
|
||||
},
|
||||
r: {
|
||||
type: 'number',
|
||||
minimum: 5,
|
||||
exclusiveMaximum: 100
|
||||
},
|
||||
id: {
|
||||
type: 'integer',
|
||||
minimum: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var data = { ts: '', r: null };
|
||||
ajv.validate(data); // true
|
||||
data; // { ts: '2016-12-01T22:07:28.829Z', r: 25, id: 0 }
|
||||
```
|
||||
|
||||
You can add your own dynamic default function to be recognised by this keyword:
|
||||
|
||||
```javascript
|
||||
var uuid = require('uuid');
|
||||
|
||||
function uuidV4() { return uuid.v4(); }
|
||||
|
||||
var definition = require('ajv-keywords').get('dynamicDefaults').definition;
|
||||
// or require('ajv-keywords/keywords/dynamicDefaults').definition;
|
||||
definition.DEFAULTS.uuid = uuidV4;
|
||||
|
||||
var schema = {
|
||||
dynamicDefaults: { id: 'uuid' },
|
||||
properties: { id: { type: 'string', format: 'uuid' } }
|
||||
};
|
||||
|
||||
var data = {};
|
||||
ajv.validate(schema, data); // true
|
||||
data; // { id: 'a1183fbe-697b-4030-9bcc-cfeb282a9150' };
|
||||
|
||||
var data1 = {};
|
||||
ajv.validate(schema, data1); // true
|
||||
data1; // { id: '5b008de7-1669-467a-a5c6-70fa244d7209' }
|
||||
```
|
||||
|
||||
You also can define dynamic default that accepts parameters, e.g. version of uuid:
|
||||
|
||||
```javascript
|
||||
var uuid = require('uuid');
|
||||
|
||||
function getUuid(args) {
|
||||
var version = 'v' + (arvs && args.v || 4);
|
||||
return function() {
|
||||
return uuid[version]();
|
||||
};
|
||||
}
|
||||
|
||||
var definition = require('ajv-keywords').get('dynamicDefaults').definition;
|
||||
definition.DEFAULTS.uuid = getUuid;
|
||||
|
||||
var schema = {
|
||||
dynamicDefaults: {
|
||||
id1: 'uuid', // v4
|
||||
id2: { func: 'uuid', v: 4 }, // v4
|
||||
id3: { func: 'uuid', v: 1 } // v1
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
## Security contact
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
Please do NOT report security vulnerabilities via GitHub issues.
|
||||
|
||||
|
||||
## Open-source software support
|
||||
|
||||
Ajv-keywords is a part of [Tidelift subscription](https://tidelift.com/subscription/pkg/npm-ajv-keywords?utm_source=npm-ajv-keywords&utm_medium=referral&utm_campaign=readme) - it provides a centralised support to open-source software users, in addition to the support provided by software maintainers.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/epoberezkin/ajv-keywords/blob/master/LICENSE)
|
7
assets_old/node_modules/ajv-keywords/ajv-keywords.d.ts
generated
vendored
Normal file
7
assets_old/node_modules/ajv-keywords/ajv-keywords.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
declare module 'ajv-keywords' {
|
||||
import { Ajv } from 'ajv';
|
||||
|
||||
function keywords(ajv: Ajv, include?: string | string[]): Ajv;
|
||||
|
||||
export = keywords;
|
||||
}
|
35
assets_old/node_modules/ajv-keywords/index.js
generated
vendored
Normal file
35
assets_old/node_modules/ajv-keywords/index.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
|
||||
var KEYWORDS = require('./keywords');
|
||||
|
||||
module.exports = defineKeywords;
|
||||
|
||||
|
||||
/**
|
||||
* Defines one or several keywords in ajv instance
|
||||
* @param {Ajv} ajv validator instance
|
||||
* @param {String|Array<String>|undefined} keyword keyword(s) to define
|
||||
* @return {Ajv} ajv instance (for chaining)
|
||||
*/
|
||||
function defineKeywords(ajv, keyword) {
|
||||
if (Array.isArray(keyword)) {
|
||||
for (var i=0; i<keyword.length; i++)
|
||||
get(keyword[i])(ajv);
|
||||
return ajv;
|
||||
}
|
||||
if (keyword) {
|
||||
get(keyword)(ajv);
|
||||
return ajv;
|
||||
}
|
||||
for (keyword in KEYWORDS) get(keyword)(ajv);
|
||||
return ajv;
|
||||
}
|
||||
|
||||
|
||||
defineKeywords.get = get;
|
||||
|
||||
function get(keyword) {
|
||||
var defFunc = KEYWORDS[keyword];
|
||||
if (!defFunc) throw new Error('Unknown keyword ' + keyword);
|
||||
return defFunc;
|
||||
}
|
101
assets_old/node_modules/ajv-keywords/keywords/_formatLimit.js
generated
vendored
Normal file
101
assets_old/node_modules/ajv-keywords/keywords/_formatLimit.js
generated
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
'use strict';
|
||||
|
||||
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i;
|
||||
var DATE_TIME_SEPARATOR = /t|\s/i;
|
||||
|
||||
var COMPARE_FORMATS = {
|
||||
date: compareDate,
|
||||
time: compareTime,
|
||||
'date-time': compareDateTime
|
||||
};
|
||||
|
||||
var $dataMetaSchema = {
|
||||
type: 'object',
|
||||
required: [ '$data' ],
|
||||
properties: {
|
||||
$data: {
|
||||
type: 'string',
|
||||
anyOf: [
|
||||
{ format: 'relative-json-pointer' },
|
||||
{ format: 'json-pointer' }
|
||||
]
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
module.exports = function (minMax) {
|
||||
var keyword = 'format' + minMax;
|
||||
return function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'string',
|
||||
inline: require('./dotjs/_formatLimit'),
|
||||
statements: true,
|
||||
errors: 'full',
|
||||
dependencies: ['format'],
|
||||
metaSchema: {
|
||||
anyOf: [
|
||||
{type: 'string'},
|
||||
$dataMetaSchema
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword(keyword, defFunc.definition);
|
||||
ajv.addKeyword('formatExclusive' + minMax, {
|
||||
dependencies: ['format' + minMax],
|
||||
metaSchema: {
|
||||
anyOf: [
|
||||
{type: 'boolean'},
|
||||
$dataMetaSchema
|
||||
]
|
||||
}
|
||||
});
|
||||
extendFormats(ajv);
|
||||
return ajv;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
function extendFormats(ajv) {
|
||||
var formats = ajv._formats;
|
||||
for (var name in COMPARE_FORMATS) {
|
||||
var format = formats[name];
|
||||
// the last condition is needed if it's RegExp from another window
|
||||
if (typeof format != 'object' || format instanceof RegExp || !format.validate)
|
||||
format = formats[name] = { validate: format };
|
||||
if (!format.compare)
|
||||
format.compare = COMPARE_FORMATS[name];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function compareDate(d1, d2) {
|
||||
if (!(d1 && d2)) return;
|
||||
if (d1 > d2) return 1;
|
||||
if (d1 < d2) return -1;
|
||||
if (d1 === d2) return 0;
|
||||
}
|
||||
|
||||
|
||||
function compareTime(t1, t2) {
|
||||
if (!(t1 && t2)) return;
|
||||
t1 = t1.match(TIME);
|
||||
t2 = t2.match(TIME);
|
||||
if (!(t1 && t2)) return;
|
||||
t1 = t1[1] + t1[2] + t1[3] + (t1[4]||'');
|
||||
t2 = t2[1] + t2[2] + t2[3] + (t2[4]||'');
|
||||
if (t1 > t2) return 1;
|
||||
if (t1 < t2) return -1;
|
||||
if (t1 === t2) return 0;
|
||||
}
|
||||
|
||||
|
||||
function compareDateTime(dt1, dt2) {
|
||||
if (!(dt1 && dt2)) return;
|
||||
dt1 = dt1.split(DATE_TIME_SEPARATOR);
|
||||
dt2 = dt2.split(DATE_TIME_SEPARATOR);
|
||||
var res = compareDate(dt1[0], dt2[0]);
|
||||
if (res === undefined) return;
|
||||
return res || compareTime(dt1[1], dt2[1]);
|
||||
}
|
15
assets_old/node_modules/ajv-keywords/keywords/_util.js
generated
vendored
Normal file
15
assets_old/node_modules/ajv-keywords/keywords/_util.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
metaSchemaRef: metaSchemaRef
|
||||
};
|
||||
|
||||
var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema';
|
||||
|
||||
function metaSchemaRef(ajv) {
|
||||
var defaultMeta = ajv._opts.defaultMeta;
|
||||
if (typeof defaultMeta == 'string') return { $ref: defaultMeta };
|
||||
if (ajv.getSchema(META_SCHEMA_ID)) return { $ref: META_SCHEMA_ID };
|
||||
console.warn('meta schema not defined');
|
||||
return {};
|
||||
}
|
18
assets_old/node_modules/ajv-keywords/keywords/allRequired.js
generated
vendored
Normal file
18
assets_old/node_modules/ajv-keywords/keywords/allRequired.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'object',
|
||||
macro: function (schema, parentSchema) {
|
||||
if (!schema) return true;
|
||||
var properties = Object.keys(parentSchema.properties);
|
||||
if (properties.length == 0) return true;
|
||||
return {required: properties};
|
||||
},
|
||||
metaSchema: {type: 'boolean'},
|
||||
dependencies: ['properties']
|
||||
};
|
||||
|
||||
ajv.addKeyword('allRequired', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
24
assets_old/node_modules/ajv-keywords/keywords/anyRequired.js
generated
vendored
Normal file
24
assets_old/node_modules/ajv-keywords/keywords/anyRequired.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'object',
|
||||
macro: function (schema) {
|
||||
if (schema.length == 0) return true;
|
||||
if (schema.length == 1) return {required: schema};
|
||||
var schemas = schema.map(function (prop) {
|
||||
return {required: [prop]};
|
||||
});
|
||||
return {anyOf: schemas};
|
||||
},
|
||||
metaSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('anyRequired', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
54
assets_old/node_modules/ajv-keywords/keywords/deepProperties.js
generated
vendored
Normal file
54
assets_old/node_modules/ajv-keywords/keywords/deepProperties.js
generated
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
'use strict';
|
||||
|
||||
var util = require('./_util');
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'object',
|
||||
macro: function (schema) {
|
||||
var schemas = [];
|
||||
for (var pointer in schema)
|
||||
schemas.push(getSchema(pointer, schema[pointer]));
|
||||
return {'allOf': schemas};
|
||||
},
|
||||
metaSchema: {
|
||||
type: 'object',
|
||||
propertyNames: {
|
||||
type: 'string',
|
||||
format: 'json-pointer'
|
||||
},
|
||||
additionalProperties: util.metaSchemaRef(ajv)
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('deepProperties', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
||||
|
||||
|
||||
function getSchema(jsonPointer, schema) {
|
||||
var segments = jsonPointer.split('/');
|
||||
var rootSchema = {};
|
||||
var pointerSchema = rootSchema;
|
||||
for (var i=1; i<segments.length; i++) {
|
||||
var segment = segments[i];
|
||||
var isLast = i == segments.length - 1;
|
||||
segment = unescapeJsonPointer(segment);
|
||||
var properties = pointerSchema.properties = {};
|
||||
var items = undefined;
|
||||
if (/[0-9]+/.test(segment)) {
|
||||
var count = +segment;
|
||||
items = pointerSchema.items = [];
|
||||
while (count--) items.push({});
|
||||
}
|
||||
pointerSchema = isLast ? schema : {};
|
||||
properties[segment] = pointerSchema;
|
||||
if (items) items.push(pointerSchema);
|
||||
}
|
||||
return rootSchema;
|
||||
}
|
||||
|
||||
|
||||
function unescapeJsonPointer(str) {
|
||||
return str.replace(/~1/g, '/').replace(/~0/g, '~');
|
||||
}
|
57
assets_old/node_modules/ajv-keywords/keywords/deepRequired.js
generated
vendored
Normal file
57
assets_old/node_modules/ajv-keywords/keywords/deepRequired.js
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'object',
|
||||
inline: function (it, keyword, schema) {
|
||||
var expr = '';
|
||||
for (var i=0; i<schema.length; i++) {
|
||||
if (i) expr += ' && ';
|
||||
expr += '(' + getData(schema[i], it.dataLevel) + ' !== undefined)';
|
||||
}
|
||||
return expr;
|
||||
},
|
||||
metaSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
format: 'json-pointer'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('deepRequired', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
||||
|
||||
|
||||
function getData(jsonPointer, lvl) {
|
||||
var data = 'data' + (lvl || '');
|
||||
if (!jsonPointer) return data;
|
||||
|
||||
var expr = data;
|
||||
var segments = jsonPointer.split('/');
|
||||
for (var i=1; i<segments.length; i++) {
|
||||
var segment = segments[i];
|
||||
data += getProperty(unescapeJsonPointer(segment));
|
||||
expr += ' && ' + data;
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
||||
|
||||
var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
|
||||
var INTEGER = /^[0-9]+$/;
|
||||
var SINGLE_QUOTE = /'|\\/g;
|
||||
function getProperty(key) {
|
||||
return INTEGER.test(key)
|
||||
? '[' + key + ']'
|
||||
: IDENTIFIER.test(key)
|
||||
? '.' + key
|
||||
: "['" + key.replace(SINGLE_QUOTE, '\\$&') + "']";
|
||||
}
|
||||
|
||||
|
||||
function unescapeJsonPointer(str) {
|
||||
return str.replace(/~1/g, '/').replace(/~0/g, '~');
|
||||
}
|
116
assets_old/node_modules/ajv-keywords/keywords/dot/_formatLimit.jst
generated
vendored
Normal file
116
assets_old/node_modules/ajv-keywords/keywords/dot/_formatLimit.jst
generated
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
{{# def.definitions }}
|
||||
{{# def.errors }}
|
||||
{{# def.setupKeyword }}
|
||||
|
||||
var {{=$valid}} = undefined;
|
||||
|
||||
{{## def.skipFormatLimit:
|
||||
{{=$valid}} = true;
|
||||
{{ return out; }}
|
||||
#}}
|
||||
|
||||
{{## def.compareFormat:
|
||||
{{? $isData }}
|
||||
if ({{=$schemaValue}} === undefined) {{=$valid}} = true;
|
||||
else if (typeof {{=$schemaValue}} != 'string') {{=$valid}} = false;
|
||||
else {
|
||||
{{ $closingBraces += '}'; }}
|
||||
{{?}}
|
||||
|
||||
{{? $isDataFormat }}
|
||||
if (!{{=$compare}}) {{=$valid}} = true;
|
||||
else {
|
||||
{{ $closingBraces += '}'; }}
|
||||
{{?}}
|
||||
|
||||
var {{=$result}} = {{=$compare}}({{=$data}}, {{# def.schemaValueQS }});
|
||||
|
||||
if ({{=$result}} === undefined) {{=$valid}} = false;
|
||||
#}}
|
||||
|
||||
|
||||
{{? it.opts.format === false }}{{# def.skipFormatLimit }}{{?}}
|
||||
|
||||
{{
|
||||
var $schemaFormat = it.schema.format
|
||||
, $isDataFormat = it.opts.$data && $schemaFormat.$data
|
||||
, $closingBraces = '';
|
||||
}}
|
||||
|
||||
{{? $isDataFormat }}
|
||||
{{
|
||||
var $schemaValueFormat = it.util.getData($schemaFormat.$data, $dataLvl, it.dataPathArr)
|
||||
, $format = 'format' + $lvl
|
||||
, $compare = 'compare' + $lvl;
|
||||
}}
|
||||
|
||||
var {{=$format}} = formats[{{=$schemaValueFormat}}]
|
||||
, {{=$compare}} = {{=$format}} && {{=$format}}.compare;
|
||||
{{??}}
|
||||
{{ var $format = it.formats[$schemaFormat]; }}
|
||||
{{? !($format && $format.compare) }}
|
||||
{{# def.skipFormatLimit }}
|
||||
{{?}}
|
||||
{{ var $compare = 'formats' + it.util.getProperty($schemaFormat) + '.compare'; }}
|
||||
{{?}}
|
||||
|
||||
{{
|
||||
var $isMax = $keyword == 'formatMaximum'
|
||||
, $exclusiveKeyword = 'formatExclusive' + ($isMax ? 'Maximum' : 'Minimum')
|
||||
, $schemaExcl = it.schema[$exclusiveKeyword]
|
||||
, $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data
|
||||
, $op = $isMax ? '<' : '>'
|
||||
, $result = 'result' + $lvl;
|
||||
}}
|
||||
|
||||
{{# def.$data }}
|
||||
|
||||
|
||||
{{? $isDataExcl }}
|
||||
{{
|
||||
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
|
||||
, $exclusive = 'exclusive' + $lvl
|
||||
, $opExpr = 'op' + $lvl
|
||||
, $opStr = '\' + ' + $opExpr + ' + \'';
|
||||
}}
|
||||
var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
|
||||
{{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
|
||||
|
||||
if (typeof {{=$schemaValueExcl}} != 'boolean' && {{=$schemaValueExcl}} !== undefined) {
|
||||
{{=$valid}} = false;
|
||||
{{ var $errorKeyword = $exclusiveKeyword; }}
|
||||
{{# def.error:'_formatExclusiveLimit' }}
|
||||
}
|
||||
|
||||
{{# def.elseIfValid }}
|
||||
|
||||
{{# def.compareFormat }}
|
||||
var {{=$exclusive}} = {{=$schemaValueExcl}} === true;
|
||||
|
||||
if ({{=$valid}} === undefined) {
|
||||
{{=$valid}} = {{=$exclusive}}
|
||||
? {{=$result}} {{=$op}} 0
|
||||
: {{=$result}} {{=$op}}= 0;
|
||||
}
|
||||
|
||||
if (!{{=$valid}}) var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
|
||||
{{??}}
|
||||
{{
|
||||
var $exclusive = $schemaExcl === true
|
||||
, $opStr = $op; /*used in error*/
|
||||
if (!$exclusive) $opStr += '=';
|
||||
var $opExpr = '\'' + $opStr + '\''; /*used in error*/
|
||||
}}
|
||||
|
||||
{{# def.compareFormat }}
|
||||
|
||||
if ({{=$valid}} === undefined)
|
||||
{{=$valid}} = {{=$result}} {{=$op}}{{?!$exclusive}}={{?}} 0;
|
||||
{{?}}
|
||||
|
||||
{{= $closingBraces }}
|
||||
|
||||
if (!{{=$valid}}) {
|
||||
{{ var $errorKeyword = $keyword; }}
|
||||
{{# def.error:'_formatLimit' }}
|
||||
}
|
33
assets_old/node_modules/ajv-keywords/keywords/dot/patternRequired.jst
generated
vendored
Normal file
33
assets_old/node_modules/ajv-keywords/keywords/dot/patternRequired.jst
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
{{# def.definitions }}
|
||||
{{# def.errors }}
|
||||
{{# def.setupKeyword }}
|
||||
|
||||
{{
|
||||
var $key = 'key' + $lvl
|
||||
, $idx = 'idx' + $lvl
|
||||
, $matched = 'patternMatched' + $lvl
|
||||
, $dataProperties = 'dataProperties' + $lvl
|
||||
, $closingBraces = ''
|
||||
, $ownProperties = it.opts.ownProperties;
|
||||
}}
|
||||
|
||||
var {{=$valid}} = true;
|
||||
{{? $ownProperties }}
|
||||
var {{=$dataProperties}} = undefined;
|
||||
{{?}}
|
||||
|
||||
{{~ $schema:$pProperty }}
|
||||
var {{=$matched}} = false;
|
||||
{{# def.iterateProperties }}
|
||||
{{=$matched}} = {{= it.usePattern($pProperty) }}.test({{=$key}});
|
||||
if ({{=$matched}}) break;
|
||||
}
|
||||
|
||||
{{ var $missingPattern = it.util.escapeQuotes($pProperty); }}
|
||||
if (!{{=$matched}}) {
|
||||
{{=$valid}} = false;
|
||||
{{# def.addError:'patternRequired' }}
|
||||
} {{# def.elseIfValid }}
|
||||
{{~}}
|
||||
|
||||
{{= $closingBraces }}
|
71
assets_old/node_modules/ajv-keywords/keywords/dot/switch.jst
generated
vendored
Normal file
71
assets_old/node_modules/ajv-keywords/keywords/dot/switch.jst
generated
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
{{# def.definitions }}
|
||||
{{# def.errors }}
|
||||
{{# def.setupKeyword }}
|
||||
{{# def.setupNextLevel }}
|
||||
|
||||
|
||||
{{## def.validateIf:
|
||||
{{# def.setCompositeRule }}
|
||||
{{ $it.createErrors = false; }}
|
||||
{{# def._validateSwitchRule:if }}
|
||||
{{ $it.createErrors = true; }}
|
||||
{{# def.resetCompositeRule }}
|
||||
{{=$ifPassed}} = {{=$nextValid}};
|
||||
#}}
|
||||
|
||||
{{## def.validateThen:
|
||||
{{? typeof $sch.then == 'boolean' }}
|
||||
{{? $sch.then === false }}
|
||||
{{# def.error:'switch' }}
|
||||
{{?}}
|
||||
var {{=$nextValid}} = {{= $sch.then }};
|
||||
{{??}}
|
||||
{{# def._validateSwitchRule:then }}
|
||||
{{?}}
|
||||
#}}
|
||||
|
||||
{{## def._validateSwitchRule:_clause:
|
||||
{{
|
||||
$it.schema = $sch._clause;
|
||||
$it.schemaPath = $schemaPath + '[' + $caseIndex + ']._clause';
|
||||
$it.errSchemaPath = $errSchemaPath + '/' + $caseIndex + '/_clause';
|
||||
}}
|
||||
{{# def.insertSubschemaCode }}
|
||||
#}}
|
||||
|
||||
{{## def.switchCase:
|
||||
{{? $sch.if && {{# def.nonEmptySchema:$sch.if }} }}
|
||||
var {{=$errs}} = errors;
|
||||
{{# def.validateIf }}
|
||||
if ({{=$ifPassed}}) {
|
||||
{{# def.validateThen }}
|
||||
} else {
|
||||
{{# def.resetErrors }}
|
||||
}
|
||||
{{??}}
|
||||
{{=$ifPassed}} = true;
|
||||
{{# def.validateThen }}
|
||||
{{?}}
|
||||
#}}
|
||||
|
||||
|
||||
{{
|
||||
var $ifPassed = 'ifPassed' + it.level
|
||||
, $currentBaseId = $it.baseId
|
||||
, $shouldContinue;
|
||||
}}
|
||||
var {{=$ifPassed}};
|
||||
|
||||
{{~ $schema:$sch:$caseIndex }}
|
||||
{{? $caseIndex && !$shouldContinue }}
|
||||
if (!{{=$ifPassed}}) {
|
||||
{{ $closingBraces+= '}'; }}
|
||||
{{?}}
|
||||
|
||||
{{# def.switchCase }}
|
||||
{{ $shouldContinue = $sch.continue }}
|
||||
{{~}}
|
||||
|
||||
{{= $closingBraces }}
|
||||
|
||||
var {{=$valid}} = {{=$nextValid}};
|
3
assets_old/node_modules/ajv-keywords/keywords/dotjs/README.md
generated
vendored
Normal file
3
assets_old/node_modules/ajv-keywords/keywords/dotjs/README.md
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
These files are compiled dot templates from dot folder.
|
||||
|
||||
Do NOT edit them directly, edit the templates and run `npm run build` from main ajv-keywords folder.
|
178
assets_old/node_modules/ajv-keywords/keywords/dotjs/_formatLimit.js
generated
vendored
Normal file
178
assets_old/node_modules/ajv-keywords/keywords/dotjs/_formatLimit.js
generated
vendored
Normal file
|
@ -0,0 +1,178 @@
|
|||
'use strict';
|
||||
module.exports = function generate__formatLimit(it, $keyword, $ruleType) {
|
||||
var out = ' ';
|
||||
var $lvl = it.level;
|
||||
var $dataLvl = it.dataLevel;
|
||||
var $schema = it.schema[$keyword];
|
||||
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
||||
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
||||
var $breakOnError = !it.opts.allErrors;
|
||||
var $errorKeyword;
|
||||
var $data = 'data' + ($dataLvl || '');
|
||||
var $valid = 'valid' + $lvl;
|
||||
out += 'var ' + ($valid) + ' = undefined;';
|
||||
if (it.opts.format === false) {
|
||||
out += ' ' + ($valid) + ' = true; ';
|
||||
return out;
|
||||
}
|
||||
var $schemaFormat = it.schema.format,
|
||||
$isDataFormat = it.opts.$data && $schemaFormat.$data,
|
||||
$closingBraces = '';
|
||||
if ($isDataFormat) {
|
||||
var $schemaValueFormat = it.util.getData($schemaFormat.$data, $dataLvl, it.dataPathArr),
|
||||
$format = 'format' + $lvl,
|
||||
$compare = 'compare' + $lvl;
|
||||
out += ' var ' + ($format) + ' = formats[' + ($schemaValueFormat) + '] , ' + ($compare) + ' = ' + ($format) + ' && ' + ($format) + '.compare;';
|
||||
} else {
|
||||
var $format = it.formats[$schemaFormat];
|
||||
if (!($format && $format.compare)) {
|
||||
out += ' ' + ($valid) + ' = true; ';
|
||||
return out;
|
||||
}
|
||||
var $compare = 'formats' + it.util.getProperty($schemaFormat) + '.compare';
|
||||
}
|
||||
var $isMax = $keyword == 'formatMaximum',
|
||||
$exclusiveKeyword = 'formatExclusive' + ($isMax ? 'Maximum' : 'Minimum'),
|
||||
$schemaExcl = it.schema[$exclusiveKeyword],
|
||||
$isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data,
|
||||
$op = $isMax ? '<' : '>',
|
||||
$result = 'result' + $lvl;
|
||||
var $isData = it.opts.$data && $schema && $schema.$data,
|
||||
$schemaValue;
|
||||
if ($isData) {
|
||||
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
|
||||
$schemaValue = 'schema' + $lvl;
|
||||
} else {
|
||||
$schemaValue = $schema;
|
||||
}
|
||||
if ($isDataExcl) {
|
||||
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
|
||||
$exclusive = 'exclusive' + $lvl,
|
||||
$opExpr = 'op' + $lvl,
|
||||
$opStr = '\' + ' + $opExpr + ' + \'';
|
||||
out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
|
||||
$schemaValueExcl = 'schemaExcl' + $lvl;
|
||||
out += ' if (typeof ' + ($schemaValueExcl) + ' != \'boolean\' && ' + ($schemaValueExcl) + ' !== undefined) { ' + ($valid) + ' = false; ';
|
||||
var $errorKeyword = $exclusiveKeyword;
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ($errorKeyword || '_formatExclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
out += ' } ';
|
||||
if ($breakOnError) {
|
||||
$closingBraces += '}';
|
||||
out += ' else { ';
|
||||
}
|
||||
if ($isData) {
|
||||
out += ' if (' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'string\') ' + ($valid) + ' = false; else { ';
|
||||
$closingBraces += '}';
|
||||
}
|
||||
if ($isDataFormat) {
|
||||
out += ' if (!' + ($compare) + ') ' + ($valid) + ' = true; else { ';
|
||||
$closingBraces += '}';
|
||||
}
|
||||
out += ' var ' + ($result) + ' = ' + ($compare) + '(' + ($data) + ', ';
|
||||
if ($isData) {
|
||||
out += '' + ($schemaValue);
|
||||
} else {
|
||||
out += '' + (it.util.toQuotedString($schema));
|
||||
}
|
||||
out += ' ); if (' + ($result) + ' === undefined) ' + ($valid) + ' = false; var ' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true; if (' + ($valid) + ' === undefined) { ' + ($valid) + ' = ' + ($exclusive) + ' ? ' + ($result) + ' ' + ($op) + ' 0 : ' + ($result) + ' ' + ($op) + '= 0; } if (!' + ($valid) + ') var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\';';
|
||||
} else {
|
||||
var $exclusive = $schemaExcl === true,
|
||||
$opStr = $op;
|
||||
if (!$exclusive) $opStr += '=';
|
||||
var $opExpr = '\'' + $opStr + '\'';
|
||||
if ($isData) {
|
||||
out += ' if (' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'string\') ' + ($valid) + ' = false; else { ';
|
||||
$closingBraces += '}';
|
||||
}
|
||||
if ($isDataFormat) {
|
||||
out += ' if (!' + ($compare) + ') ' + ($valid) + ' = true; else { ';
|
||||
$closingBraces += '}';
|
||||
}
|
||||
out += ' var ' + ($result) + ' = ' + ($compare) + '(' + ($data) + ', ';
|
||||
if ($isData) {
|
||||
out += '' + ($schemaValue);
|
||||
} else {
|
||||
out += '' + (it.util.toQuotedString($schema));
|
||||
}
|
||||
out += ' ); if (' + ($result) + ' === undefined) ' + ($valid) + ' = false; if (' + ($valid) + ' === undefined) ' + ($valid) + ' = ' + ($result) + ' ' + ($op);
|
||||
if (!$exclusive) {
|
||||
out += '=';
|
||||
}
|
||||
out += ' 0;';
|
||||
}
|
||||
out += '' + ($closingBraces) + 'if (!' + ($valid) + ') { ';
|
||||
var $errorKeyword = $keyword;
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ($errorKeyword || '_formatLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ';
|
||||
if ($isData) {
|
||||
out += '' + ($schemaValue);
|
||||
} else {
|
||||
out += '' + (it.util.toQuotedString($schema));
|
||||
}
|
||||
out += ' , exclusive: ' + ($exclusive) + ' } ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'should be ' + ($opStr) + ' "';
|
||||
if ($isData) {
|
||||
out += '\' + ' + ($schemaValue) + ' + \'';
|
||||
} else {
|
||||
out += '' + (it.util.escapeQuotes($schema));
|
||||
}
|
||||
out += '"\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: ';
|
||||
if ($isData) {
|
||||
out += 'validate.schema' + ($schemaPath);
|
||||
} else {
|
||||
out += '' + (it.util.toQuotedString($schema));
|
||||
}
|
||||
out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
out += '}';
|
||||
return out;
|
||||
}
|
58
assets_old/node_modules/ajv-keywords/keywords/dotjs/patternRequired.js
generated
vendored
Normal file
58
assets_old/node_modules/ajv-keywords/keywords/dotjs/patternRequired.js
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
'use strict';
|
||||
module.exports = function generate_patternRequired(it, $keyword, $ruleType) {
|
||||
var out = ' ';
|
||||
var $lvl = it.level;
|
||||
var $dataLvl = it.dataLevel;
|
||||
var $schema = it.schema[$keyword];
|
||||
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
||||
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
||||
var $breakOnError = !it.opts.allErrors;
|
||||
var $data = 'data' + ($dataLvl || '');
|
||||
var $valid = 'valid' + $lvl;
|
||||
var $key = 'key' + $lvl,
|
||||
$idx = 'idx' + $lvl,
|
||||
$matched = 'patternMatched' + $lvl,
|
||||
$dataProperties = 'dataProperties' + $lvl,
|
||||
$closingBraces = '',
|
||||
$ownProperties = it.opts.ownProperties;
|
||||
out += 'var ' + ($valid) + ' = true;';
|
||||
if ($ownProperties) {
|
||||
out += ' var ' + ($dataProperties) + ' = undefined;';
|
||||
}
|
||||
var arr1 = $schema;
|
||||
if (arr1) {
|
||||
var $pProperty, i1 = -1,
|
||||
l1 = arr1.length - 1;
|
||||
while (i1 < l1) {
|
||||
$pProperty = arr1[i1 += 1];
|
||||
out += ' var ' + ($matched) + ' = false; ';
|
||||
if ($ownProperties) {
|
||||
out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
|
||||
} else {
|
||||
out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
|
||||
}
|
||||
out += ' ' + ($matched) + ' = ' + (it.usePattern($pProperty)) + '.test(' + ($key) + '); if (' + ($matched) + ') break; } ';
|
||||
var $missingPattern = it.util.escapeQuotes($pProperty);
|
||||
out += ' if (!' + ($matched) + ') { ' + ($valid) + ' = false; var err = '; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ('patternRequired') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingPattern: \'' + ($missingPattern) + '\' } ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'should have property matching pattern \\\'' + ($missingPattern) + '\\\'\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
|
||||
if ($breakOnError) {
|
||||
$closingBraces += '}';
|
||||
out += ' else { ';
|
||||
}
|
||||
}
|
||||
}
|
||||
out += '' + ($closingBraces);
|
||||
return out;
|
||||
}
|
129
assets_old/node_modules/ajv-keywords/keywords/dotjs/switch.js
generated
vendored
Normal file
129
assets_old/node_modules/ajv-keywords/keywords/dotjs/switch.js
generated
vendored
Normal file
|
@ -0,0 +1,129 @@
|
|||
'use strict';
|
||||
module.exports = function generate_switch(it, $keyword, $ruleType) {
|
||||
var out = ' ';
|
||||
var $lvl = it.level;
|
||||
var $dataLvl = it.dataLevel;
|
||||
var $schema = it.schema[$keyword];
|
||||
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
||||
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
||||
var $breakOnError = !it.opts.allErrors;
|
||||
var $data = 'data' + ($dataLvl || '');
|
||||
var $valid = 'valid' + $lvl;
|
||||
var $errs = 'errs__' + $lvl;
|
||||
var $it = it.util.copy(it);
|
||||
var $closingBraces = '';
|
||||
$it.level++;
|
||||
var $nextValid = 'valid' + $it.level;
|
||||
var $ifPassed = 'ifPassed' + it.level,
|
||||
$currentBaseId = $it.baseId,
|
||||
$shouldContinue;
|
||||
out += 'var ' + ($ifPassed) + ';';
|
||||
var arr1 = $schema;
|
||||
if (arr1) {
|
||||
var $sch, $caseIndex = -1,
|
||||
l1 = arr1.length - 1;
|
||||
while ($caseIndex < l1) {
|
||||
$sch = arr1[$caseIndex += 1];
|
||||
if ($caseIndex && !$shouldContinue) {
|
||||
out += ' if (!' + ($ifPassed) + ') { ';
|
||||
$closingBraces += '}';
|
||||
}
|
||||
if ($sch.if && (it.opts.strictKeywords ? typeof $sch.if == 'object' && Object.keys($sch.if).length > 0 : it.util.schemaHasRules($sch.if, it.RULES.all))) {
|
||||
out += ' var ' + ($errs) + ' = errors; ';
|
||||
var $wasComposite = it.compositeRule;
|
||||
it.compositeRule = $it.compositeRule = true;
|
||||
$it.createErrors = false;
|
||||
$it.schema = $sch.if;
|
||||
$it.schemaPath = $schemaPath + '[' + $caseIndex + '].if';
|
||||
$it.errSchemaPath = $errSchemaPath + '/' + $caseIndex + '/if';
|
||||
out += ' ' + (it.validate($it)) + ' ';
|
||||
$it.baseId = $currentBaseId;
|
||||
$it.createErrors = true;
|
||||
it.compositeRule = $it.compositeRule = $wasComposite;
|
||||
out += ' ' + ($ifPassed) + ' = ' + ($nextValid) + '; if (' + ($ifPassed) + ') { ';
|
||||
if (typeof $sch.then == 'boolean') {
|
||||
if ($sch.then === false) {
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ('switch') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { caseIndex: ' + ($caseIndex) + ' } ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'should pass "switch" keyword validation\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
}
|
||||
out += ' var ' + ($nextValid) + ' = ' + ($sch.then) + '; ';
|
||||
} else {
|
||||
$it.schema = $sch.then;
|
||||
$it.schemaPath = $schemaPath + '[' + $caseIndex + '].then';
|
||||
$it.errSchemaPath = $errSchemaPath + '/' + $caseIndex + '/then';
|
||||
out += ' ' + (it.validate($it)) + ' ';
|
||||
$it.baseId = $currentBaseId;
|
||||
}
|
||||
out += ' } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } } ';
|
||||
} else {
|
||||
out += ' ' + ($ifPassed) + ' = true; ';
|
||||
if (typeof $sch.then == 'boolean') {
|
||||
if ($sch.then === false) {
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ('switch') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { caseIndex: ' + ($caseIndex) + ' } ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'should pass "switch" keyword validation\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
}
|
||||
out += ' var ' + ($nextValid) + ' = ' + ($sch.then) + '; ';
|
||||
} else {
|
||||
$it.schema = $sch.then;
|
||||
$it.schemaPath = $schemaPath + '[' + $caseIndex + '].then';
|
||||
$it.errSchemaPath = $errSchemaPath + '/' + $caseIndex + '/then';
|
||||
out += ' ' + (it.validate($it)) + ' ';
|
||||
$it.baseId = $currentBaseId;
|
||||
}
|
||||
}
|
||||
$shouldContinue = $sch.continue
|
||||
}
|
||||
}
|
||||
out += '' + ($closingBraces) + 'var ' + ($valid) + ' = ' + ($nextValid) + ';';
|
||||
return out;
|
||||
}
|
72
assets_old/node_modules/ajv-keywords/keywords/dynamicDefaults.js
generated
vendored
Normal file
72
assets_old/node_modules/ajv-keywords/keywords/dynamicDefaults.js
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
'use strict';
|
||||
|
||||
var sequences = {};
|
||||
|
||||
var DEFAULTS = {
|
||||
timestamp: function() { return Date.now(); },
|
||||
datetime: function() { return (new Date).toISOString(); },
|
||||
date: function() { return (new Date).toISOString().slice(0, 10); },
|
||||
time: function() { return (new Date).toISOString().slice(11); },
|
||||
random: function() { return Math.random(); },
|
||||
randomint: function (args) {
|
||||
var limit = args && args.max || 2;
|
||||
return function() { return Math.floor(Math.random() * limit); };
|
||||
},
|
||||
seq: function (args) {
|
||||
var name = args && args.name || '';
|
||||
sequences[name] = sequences[name] || 0;
|
||||
return function() { return sequences[name]++; };
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
compile: function (schema, parentSchema, it) {
|
||||
var funcs = {};
|
||||
|
||||
for (var key in schema) {
|
||||
var d = schema[key];
|
||||
var func = getDefault(typeof d == 'string' ? d : d.func);
|
||||
funcs[key] = func.length ? func(d.args) : func;
|
||||
}
|
||||
|
||||
return it.opts.useDefaults && !it.compositeRule
|
||||
? assignDefaults
|
||||
: noop;
|
||||
|
||||
function assignDefaults(data) {
|
||||
for (var prop in schema){
|
||||
if (data[prop] === undefined
|
||||
|| (it.opts.useDefaults == 'empty'
|
||||
&& (data[prop] === null || data[prop] === '')))
|
||||
data[prop] = funcs[prop]();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function noop() { return true; }
|
||||
},
|
||||
DEFAULTS: DEFAULTS,
|
||||
metaSchema: {
|
||||
type: 'object',
|
||||
additionalProperties: {
|
||||
type: ['string', 'object'],
|
||||
additionalProperties: false,
|
||||
required: ['func', 'args'],
|
||||
properties: {
|
||||
func: { type: 'string' },
|
||||
args: { type: 'object' }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('dynamicDefaults', defFunc.definition);
|
||||
return ajv;
|
||||
|
||||
function getDefault(d) {
|
||||
var def = DEFAULTS[d];
|
||||
if (def) return def;
|
||||
throw new Error('invalid "dynamicDefaults" keyword property value: ' + d);
|
||||
}
|
||||
};
|
3
assets_old/node_modules/ajv-keywords/keywords/formatMaximum.js
generated
vendored
Normal file
3
assets_old/node_modules/ajv-keywords/keywords/formatMaximum.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = require('./_formatLimit')('Maximum');
|
3
assets_old/node_modules/ajv-keywords/keywords/formatMinimum.js
generated
vendored
Normal file
3
assets_old/node_modules/ajv-keywords/keywords/formatMinimum.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = require('./_formatLimit')('Minimum');
|
22
assets_old/node_modules/ajv-keywords/keywords/index.js
generated
vendored
Normal file
22
assets_old/node_modules/ajv-keywords/keywords/index.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
'instanceof': require('./instanceof'),
|
||||
range: require('./range'),
|
||||
regexp: require('./regexp'),
|
||||
'typeof': require('./typeof'),
|
||||
dynamicDefaults: require('./dynamicDefaults'),
|
||||
allRequired: require('./allRequired'),
|
||||
anyRequired: require('./anyRequired'),
|
||||
oneRequired: require('./oneRequired'),
|
||||
prohibited: require('./prohibited'),
|
||||
uniqueItemProperties: require('./uniqueItemProperties'),
|
||||
deepProperties: require('./deepProperties'),
|
||||
deepRequired: require('./deepRequired'),
|
||||
formatMinimum: require('./formatMinimum'),
|
||||
formatMaximum: require('./formatMaximum'),
|
||||
patternRequired: require('./patternRequired'),
|
||||
'switch': require('./switch'),
|
||||
select: require('./select'),
|
||||
transform: require('./transform')
|
||||
};
|
58
assets_old/node_modules/ajv-keywords/keywords/instanceof.js
generated
vendored
Normal file
58
assets_old/node_modules/ajv-keywords/keywords/instanceof.js
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
'use strict';
|
||||
|
||||
var CONSTRUCTORS = {
|
||||
Object: Object,
|
||||
Array: Array,
|
||||
Function: Function,
|
||||
Number: Number,
|
||||
String: String,
|
||||
Date: Date,
|
||||
RegExp: RegExp
|
||||
};
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
/* istanbul ignore else */
|
||||
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') {
|
||||
var Constructor = getConstructor(schema);
|
||||
return function (data) {
|
||||
return data instanceof Constructor;
|
||||
};
|
||||
}
|
||||
|
||||
var constructors = schema.map(getConstructor);
|
||||
return function (data) {
|
||||
for (var i=0; i<constructors.length; i++)
|
||||
if (data instanceof constructors[i]) return true;
|
||||
return false;
|
||||
};
|
||||
},
|
||||
CONSTRUCTORS: CONSTRUCTORS,
|
||||
metaSchema: {
|
||||
anyOf: [
|
||||
{ type: 'string' },
|
||||
{
|
||||
type: 'array',
|
||||
items: { type: 'string' }
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('instanceof', defFunc.definition);
|
||||
return ajv;
|
||||
|
||||
function getConstructor(c) {
|
||||
var Constructor = CONSTRUCTORS[c];
|
||||
if (Constructor) return Constructor;
|
||||
throw new Error('invalid "instanceof" keyword value ' + c);
|
||||
}
|
||||
};
|
24
assets_old/node_modules/ajv-keywords/keywords/oneRequired.js
generated
vendored
Normal file
24
assets_old/node_modules/ajv-keywords/keywords/oneRequired.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'object',
|
||||
macro: function (schema) {
|
||||
if (schema.length == 0) return true;
|
||||
if (schema.length == 1) return {required: schema};
|
||||
var schemas = schema.map(function (prop) {
|
||||
return {required: [prop]};
|
||||
});
|
||||
return {oneOf: schemas};
|
||||
},
|
||||
metaSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('oneRequired', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
21
assets_old/node_modules/ajv-keywords/keywords/patternRequired.js
generated
vendored
Normal file
21
assets_old/node_modules/ajv-keywords/keywords/patternRequired.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'object',
|
||||
inline: require('./dotjs/patternRequired'),
|
||||
statements: true,
|
||||
errors: 'full',
|
||||
metaSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
format: 'regex'
|
||||
},
|
||||
uniqueItems: true
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('patternRequired', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
24
assets_old/node_modules/ajv-keywords/keywords/prohibited.js
generated
vendored
Normal file
24
assets_old/node_modules/ajv-keywords/keywords/prohibited.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'object',
|
||||
macro: function (schema) {
|
||||
if (schema.length == 0) return true;
|
||||
if (schema.length == 1) return {not: {required: schema}};
|
||||
var schemas = schema.map(function (prop) {
|
||||
return {required: [prop]};
|
||||
});
|
||||
return {not: {anyOf: schemas}};
|
||||
},
|
||||
metaSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('prohibited', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
36
assets_old/node_modules/ajv-keywords/keywords/range.js
generated
vendored
Normal file
36
assets_old/node_modules/ajv-keywords/keywords/range.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'number',
|
||||
macro: function (schema, parentSchema) {
|
||||
var min = schema[0]
|
||||
, max = schema[1]
|
||||
, exclusive = parentSchema.exclusiveRange;
|
||||
|
||||
validateRangeSchema(min, max, exclusive);
|
||||
|
||||
return exclusive === true
|
||||
? {exclusiveMinimum: min, exclusiveMaximum: max}
|
||||
: {minimum: min, maximum: max};
|
||||
},
|
||||
metaSchema: {
|
||||
type: 'array',
|
||||
minItems: 2,
|
||||
maxItems: 2,
|
||||
items: { type: 'number' }
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('range', defFunc.definition);
|
||||
ajv.addKeyword('exclusiveRange');
|
||||
return ajv;
|
||||
|
||||
function validateRangeSchema(min, max, exclusive) {
|
||||
if (exclusive !== undefined && typeof exclusive != 'boolean')
|
||||
throw new Error('Invalid schema for exclusiveRange keyword, should be boolean');
|
||||
|
||||
if (min > max || (exclusive && min == max))
|
||||
throw new Error('There are no numbers in range');
|
||||
}
|
||||
};
|
36
assets_old/node_modules/ajv-keywords/keywords/regexp.js
generated
vendored
Normal file
36
assets_old/node_modules/ajv-keywords/keywords/regexp.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'string',
|
||||
inline: function (it, keyword, schema) {
|
||||
return getRegExp() + '.test(data' + (it.dataLevel || '') + ')';
|
||||
|
||||
function getRegExp() {
|
||||
try {
|
||||
if (typeof schema == 'object')
|
||||
return new RegExp(schema.pattern, schema.flags);
|
||||
|
||||
var rx = schema.match(/^\/(.*)\/([gimuy]*)$/);
|
||||
if (rx) return new RegExp(rx[1], rx[2]);
|
||||
throw new Error('cannot parse string into RegExp');
|
||||
} catch(e) {
|
||||
console.error('regular expression', schema, 'is invalid');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
},
|
||||
metaSchema: {
|
||||
type: ['string', 'object'],
|
||||
properties: {
|
||||
pattern: { type: 'string' },
|
||||
flags: { type: 'string' }
|
||||
},
|
||||
required: ['pattern'],
|
||||
additionalProperties: false
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('regexp', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
79
assets_old/node_modules/ajv-keywords/keywords/select.js
generated
vendored
Normal file
79
assets_old/node_modules/ajv-keywords/keywords/select.js
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
'use strict';
|
||||
|
||||
var util = require('./_util');
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
if (!ajv._opts.$data) {
|
||||
console.warn('keyword select requires $data option');
|
||||
return ajv;
|
||||
}
|
||||
var metaSchemaRef = util.metaSchemaRef(ajv);
|
||||
var compiledCaseSchemas = [];
|
||||
|
||||
defFunc.definition = {
|
||||
validate: function v(schema, data, parentSchema) {
|
||||
if (parentSchema.selectCases === undefined)
|
||||
throw new Error('keyword "selectCases" is absent');
|
||||
var compiled = getCompiledSchemas(parentSchema, false);
|
||||
var validate = compiled.cases[schema];
|
||||
if (validate === undefined) validate = compiled.default;
|
||||
if (typeof validate == 'boolean') return validate;
|
||||
var valid = validate(data);
|
||||
if (!valid) v.errors = validate.errors;
|
||||
return valid;
|
||||
},
|
||||
$data: true,
|
||||
metaSchema: { type: ['string', 'number', 'boolean', 'null'] }
|
||||
};
|
||||
|
||||
ajv.addKeyword('select', defFunc.definition);
|
||||
ajv.addKeyword('selectCases', {
|
||||
compile: function (schemas, parentSchema) {
|
||||
var compiled = getCompiledSchemas(parentSchema);
|
||||
for (var value in schemas)
|
||||
compiled.cases[value] = compileOrBoolean(schemas[value]);
|
||||
return function() { return true; };
|
||||
},
|
||||
valid: true,
|
||||
metaSchema: {
|
||||
type: 'object',
|
||||
additionalProperties: metaSchemaRef
|
||||
}
|
||||
});
|
||||
ajv.addKeyword('selectDefault', {
|
||||
compile: function (schema, parentSchema) {
|
||||
var compiled = getCompiledSchemas(parentSchema);
|
||||
compiled.default = compileOrBoolean(schema);
|
||||
return function() { return true; };
|
||||
},
|
||||
valid: true,
|
||||
metaSchema: metaSchemaRef
|
||||
});
|
||||
return ajv;
|
||||
|
||||
|
||||
function getCompiledSchemas(parentSchema, create) {
|
||||
var compiled;
|
||||
compiledCaseSchemas.some(function (c) {
|
||||
if (c.parentSchema === parentSchema) {
|
||||
compiled = c;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (!compiled && create !== false) {
|
||||
compiled = {
|
||||
parentSchema: parentSchema,
|
||||
cases: {},
|
||||
default: true
|
||||
};
|
||||
compiledCaseSchemas.push(compiled);
|
||||
}
|
||||
return compiled;
|
||||
}
|
||||
|
||||
function compileOrBoolean(schema) {
|
||||
return typeof schema == 'boolean'
|
||||
? schema
|
||||
: ajv.compile(schema);
|
||||
}
|
||||
};
|
38
assets_old/node_modules/ajv-keywords/keywords/switch.js
generated
vendored
Normal file
38
assets_old/node_modules/ajv-keywords/keywords/switch.js
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
var util = require('./_util');
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
if (ajv.RULES.keywords.switch && ajv.RULES.keywords.if) return;
|
||||
|
||||
var metaSchemaRef = util.metaSchemaRef(ajv);
|
||||
|
||||
defFunc.definition = {
|
||||
inline: require('./dotjs/switch'),
|
||||
statements: true,
|
||||
errors: 'full',
|
||||
metaSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
required: [ 'then' ],
|
||||
properties: {
|
||||
'if': metaSchemaRef,
|
||||
'then': {
|
||||
anyOf: [
|
||||
{ type: 'boolean' },
|
||||
metaSchemaRef
|
||||
]
|
||||
},
|
||||
'continue': { type: 'boolean' }
|
||||
},
|
||||
additionalProperties: false,
|
||||
dependencies: {
|
||||
'continue': [ 'if' ]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('switch', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
80
assets_old/node_modules/ajv-keywords/keywords/transform.js
generated
vendored
Normal file
80
assets_old/node_modules/ajv-keywords/keywords/transform.js
generated
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function defFunc (ajv) {
|
||||
var transform = {
|
||||
trimLeft: function (value) {
|
||||
return value.replace(/^[\s]+/, '');
|
||||
},
|
||||
trimRight: function (value) {
|
||||
return value.replace(/[\s]+$/, '');
|
||||
},
|
||||
trim: function (value) {
|
||||
return value.trim();
|
||||
},
|
||||
toLowerCase: function (value) {
|
||||
return value.toLowerCase();
|
||||
},
|
||||
toUpperCase: function (value) {
|
||||
return value.toUpperCase();
|
||||
},
|
||||
toEnumCase: function (value, cfg) {
|
||||
return cfg.hash[makeHashTableKey(value)] || value;
|
||||
}
|
||||
};
|
||||
|
||||
defFunc.definition = {
|
||||
type: 'string',
|
||||
errors: false,
|
||||
modifying: true,
|
||||
valid: true,
|
||||
compile: function (schema, parentSchema) {
|
||||
var cfg;
|
||||
|
||||
if (schema.indexOf('toEnumCase') !== -1) {
|
||||
// build hash table to enum values
|
||||
cfg = {hash: {}};
|
||||
|
||||
// requires `enum` in schema
|
||||
if (!parentSchema.enum)
|
||||
throw new Error('Missing enum. To use `transform:["toEnumCase"]`, `enum:[...]` is required.');
|
||||
for (var i = parentSchema.enum.length; i--; i) {
|
||||
var v = parentSchema.enum[i];
|
||||
if (typeof v !== 'string') continue;
|
||||
var k = makeHashTableKey(v);
|
||||
// requires all `enum` values have unique keys
|
||||
if (cfg.hash[k])
|
||||
throw new Error('Invalid enum uniqueness. To use `transform:["toEnumCase"]`, all values must be unique when case insensitive.');
|
||||
cfg.hash[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
return function (data, dataPath, object, key) {
|
||||
// skip if value only
|
||||
if (!object) return;
|
||||
|
||||
// apply transform in order provided
|
||||
for (var j = 0, l = schema.length; j < l; j++)
|
||||
data = transform[schema[j]](data, cfg);
|
||||
|
||||
object[key] = data;
|
||||
};
|
||||
},
|
||||
metaSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'trimLeft', 'trimRight', 'trim',
|
||||
'toLowerCase', 'toUpperCase', 'toEnumCase'
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('transform', defFunc.definition);
|
||||
return ajv;
|
||||
|
||||
function makeHashTableKey (value) {
|
||||
return value.toLowerCase();
|
||||
}
|
||||
};
|
32
assets_old/node_modules/ajv-keywords/keywords/typeof.js
generated
vendored
Normal file
32
assets_old/node_modules/ajv-keywords/keywords/typeof.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
var KNOWN_TYPES = ['undefined', 'string', 'number', 'object', 'function', 'boolean', 'symbol'];
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
inline: function (it, keyword, schema) {
|
||||
var data = 'data' + (it.dataLevel || '');
|
||||
if (typeof schema == 'string') return 'typeof ' + data + ' == "' + schema + '"';
|
||||
schema = 'validate.schema' + it.schemaPath + '.' + keyword;
|
||||
return schema + '.indexOf(typeof ' + data + ') >= 0';
|
||||
},
|
||||
metaSchema: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string',
|
||||
enum: KNOWN_TYPES
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: KNOWN_TYPES
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('typeof', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
59
assets_old/node_modules/ajv-keywords/keywords/uniqueItemProperties.js
generated
vendored
Normal file
59
assets_old/node_modules/ajv-keywords/keywords/uniqueItemProperties.js
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
'use strict';
|
||||
|
||||
var SCALAR_TYPES = ['number', 'integer', 'string', 'boolean', 'null'];
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
defFunc.definition = {
|
||||
type: 'array',
|
||||
compile: function(keys, parentSchema, it) {
|
||||
var equal = it.util.equal;
|
||||
var scalar = getScalarKeys(keys, parentSchema);
|
||||
|
||||
return function(data) {
|
||||
if (data.length > 1) {
|
||||
for (var k=0; k < keys.length; k++) {
|
||||
var i, key = keys[k];
|
||||
if (scalar[k]) {
|
||||
var hash = {};
|
||||
for (i = data.length; i--;) {
|
||||
if (!data[i] || typeof data[i] != 'object') continue;
|
||||
var prop = data[i][key];
|
||||
if (prop && typeof prop == 'object') continue;
|
||||
if (typeof prop == 'string') prop = '"' + prop;
|
||||
if (hash[prop]) return false;
|
||||
hash[prop] = true;
|
||||
}
|
||||
} else {
|
||||
for (i = data.length; i--;) {
|
||||
if (!data[i] || typeof data[i] != 'object') continue;
|
||||
for (var j = i; j--;) {
|
||||
if (data[j] && typeof data[j] == 'object' && equal(data[i][key], data[j][key]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
},
|
||||
metaSchema: {
|
||||
type: 'array',
|
||||
items: {type: 'string'}
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('uniqueItemProperties', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
||||
|
||||
|
||||
function getScalarKeys(keys, schema) {
|
||||
return keys.map(function(key) {
|
||||
var properties = schema.items && schema.items.properties;
|
||||
var propType = properties && properties[key] && properties[key].type;
|
||||
return Array.isArray(propType)
|
||||
? propType.indexOf('object') < 0 && propType.indexOf('array') < 0
|
||||
: SCALAR_TYPES.indexOf(propType) >= 0;
|
||||
});
|
||||
}
|
53
assets_old/node_modules/ajv-keywords/package.json
generated
vendored
Normal file
53
assets_old/node_modules/ajv-keywords/package.json
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"name": "ajv-keywords",
|
||||
"version": "3.5.2",
|
||||
"description": "Custom JSON-Schema keywords for Ajv validator",
|
||||
"main": "index.js",
|
||||
"typings": "ajv-keywords.d.ts",
|
||||
"scripts": {
|
||||
"build": "node node_modules/ajv/scripts/compile-dots.js node_modules/ajv/lib keywords",
|
||||
"prepublish": "npm run build",
|
||||
"test": "npm run build && npm run eslint && npm run test-cov",
|
||||
"eslint": "eslint index.js keywords/*.js spec",
|
||||
"test-spec": "mocha spec/*.spec.js -R spec",
|
||||
"test-cov": "istanbul cover -x 'spec/**' node_modules/mocha/bin/_mocha -- spec/*.spec.js -R spec"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/epoberezkin/ajv-keywords.git"
|
||||
},
|
||||
"keywords": [
|
||||
"JSON-Schema",
|
||||
"ajv",
|
||||
"keywords"
|
||||
],
|
||||
"files": [
|
||||
"index.js",
|
||||
"ajv-keywords.d.ts",
|
||||
"keywords"
|
||||
],
|
||||
"author": "Evgeny Poberezkin",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/epoberezkin/ajv-keywords/issues"
|
||||
},
|
||||
"homepage": "https://github.com/epoberezkin/ajv-keywords#readme",
|
||||
"peerDependencies": {
|
||||
"ajv": "^6.9.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ajv": "^6.9.1",
|
||||
"ajv-pack": "^0.3.0",
|
||||
"chai": "^4.2.0",
|
||||
"coveralls": "^3.0.2",
|
||||
"dot": "^1.1.1",
|
||||
"eslint": "^7.2.0",
|
||||
"glob": "^7.1.3",
|
||||
"istanbul": "^0.4.3",
|
||||
"js-beautify": "^1.8.9",
|
||||
"json-schema-test": "^2.0.0",
|
||||
"mocha": "^8.0.1",
|
||||
"pre-commit": "^1.1.3",
|
||||
"uuid": "^8.1.0"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue