BVB Source Codes

reactide Show uniqueItems.js Source code

Return Download reactide: download uniqueItems.js Source code - Download reactide Source code - Type:.js
  1. 'use strict';
  2. module.exports = function generate_uniqueItems(it, $keyword) {
  3.   var out = ' ';
  4.   var $lvl = it.level;
  5.   var $dataLvl = it.dataLevel;
  6.   var $schema = it.schema[$keyword];
  7.   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  8.   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  9.   var $breakOnError = !it.opts.allErrors;
  10.   var $errorKeyword;
  11.   var $data = 'data' + ($dataLvl || '');
  12.   var $valid = 'valid' + $lvl;
  13.   var $isData = it.opts.v5 && $schema && $schema.$data,
  14.     $schemaValue;
  15.   if ($isData) {
  16.     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  17.     $schemaValue = 'schema' + $lvl;
  18.   } else {
  19.     $schemaValue = $schema;
  20.   }
  21.   if (($schema || $isData) && it.opts.uniqueItems !== false) {
  22.     if ($isData) {
  23.       out += ' var ' + ($valid) + '; if (' + ($schemaValue) + ' === false || ' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'boolean\') ' + ($valid) + ' = false; else { ';
  24.     }
  25.     out += ' var ' + ($valid) + ' = true; if (' + ($data) + '.length > 1) { var i = ' + ($data) + '.length, j; outer: for (;i--;) { for (j = i; j--;) { if (equal(' + ($data) + '[i], ' + ($data) + '[j])) { ' + ($valid) + ' = false; break outer; } } } } ';
  26.     if ($isData) {
  27.       out += '  }  ';
  28.     }
  29.     out += ' if (!' + ($valid) + ') {   ';
  30.     var $$outStack = $$outStack || [];
  31.     $$outStack.push(out);
  32.     out = ''; /* istanbul ignore else */
  33.     if (it.createErrors !== false) {
  34.       out += ' { keyword: \'' + ($errorKeyword || 'uniqueItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { i: i, j: j } ';
  35.       if (it.opts.messages !== false) {
  36.         out += ' , message: \'should NOT have duplicate items (items ## \' + j + \' and \' + i + \' are identical)\' ';
  37.       }
  38.       if (it.opts.verbose) {
  39.         out += ' , schema:  ';
  40.         if ($isData) {
  41.           out += 'validate.schema' + ($schemaPath);
  42.         } else {
  43.           out += '' + ($schema);
  44.         }
  45.         out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  46.       }
  47.       out += ' } ';
  48.     } else {
  49.       out += ' {} ';
  50.     }
  51.     var __err = out;
  52.     out = $$outStack.pop();
  53.     if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  54.       if (it.async) {
  55.         out += ' throw new ValidationError([' + (__err) + ']); ';
  56.       } else {
  57.         out += ' validate.errors = [' + (__err) + ']; return false; ';
  58.       }
  59.     } else {
  60.       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  61.     }
  62.     out += ' } ';
  63.     if ($breakOnError) {
  64.       out += ' else { ';
  65.     }
  66.   } else {
  67.     if ($breakOnError) {
  68.       out += ' if (true) { ';
  69.     }
  70.   }
  71.   return out;
  72. }
  73.  
downloaduniqueItems.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top