BVB Source Codes

reactide Show enum.js Source code

Return Download reactide: download enum.js Source code - Download reactide Source code - Type:.js
  1. 'use strict';
  2. module.exports = function generate_enum(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.   var $i = 'i' + $lvl,
  22.     $vSchema = 'schema' + $lvl;
  23.   if (!$isData) {
  24.     out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + ';';
  25.   }
  26.   out += 'var ' + ($valid) + ';';
  27.   if ($isData) {
  28.     out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {';
  29.   }
  30.   out += '' + ($valid) + ' = false;for (var ' + ($i) + '=0; ' + ($i) + '<' + ($vSchema) + '.length; ' + ($i) + '++) if (equal(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + '])) { ' + ($valid) + ' = true; break; }';
  31.   if ($isData) {
  32.     out += '  }  ';
  33.   }
  34.   out += ' if (!' + ($valid) + ') {   ';
  35.   var $$outStack = $$outStack || [];
  36.   $$outStack.push(out);
  37.   out = ''; /* istanbul ignore else */
  38.   if (it.createErrors !== false) {
  39.     out += ' { keyword: \'' + ($errorKeyword || 'enum') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValues: schema' + ($lvl) + ' } ';
  40.     if (it.opts.messages !== false) {
  41.       out += ' , message: \'should be equal to one of the allowed values\' ';
  42.     }
  43.     if (it.opts.verbose) {
  44.       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  45.     }
  46.     out += ' } ';
  47.   } else {
  48.     out += ' {} ';
  49.   }
  50.   var __err = out;
  51.   out = $$outStack.pop();
  52.   if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  53.     if (it.async) {
  54.       out += ' throw new ValidationError([' + (__err) + ']); ';
  55.     } else {
  56.       out += ' validate.errors = [' + (__err) + ']; return false; ';
  57.     }
  58.   } else {
  59.     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  60.   }
  61.   out += ' }';
  62.   if ($breakOnError) {
  63.     out += ' else { ';
  64.   }
  65.   return out;
  66. }
  67.  
downloadenum.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