summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/har-validator/node_modules/ajv/lib/dotjs/constant.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/har-validator/node_modules/ajv/lib/dotjs/constant.js')
-rw-r--r--deps/npm/node_modules/har-validator/node_modules/ajv/lib/dotjs/constant.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/deps/npm/node_modules/har-validator/node_modules/ajv/lib/dotjs/constant.js b/deps/npm/node_modules/har-validator/node_modules/ajv/lib/dotjs/constant.js
new file mode 100644
index 0000000000..2a3e147ff4
--- /dev/null
+++ b/deps/npm/node_modules/har-validator/node_modules/ajv/lib/dotjs/constant.js
@@ -0,0 +1,52 @@
+'use strict';
+module.exports = function generate_constant(it, $keyword) {
+ 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 $isData = it.opts.v5 && $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 (!$isData) {
+ out += ' var schema' + ($lvl) + ' = validate.schema' + ($schemaPath) + ';';
+ }
+ out += 'var ' + ($valid) + ' = equal(' + ($data) + ', schema' + ($lvl) + '); if (!' + ($valid) + ') { ';
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = ''; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ('constant') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'should be equal to constant\' ';
+ }
+ 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 += ' }';
+ return out;
+}