BVB Source Codes

reactide Show patternRequired.js Source code

Return Download reactide: download patternRequired.js Source code - Download reactide Source code - Type:.js
  1. 'use strict';
  2. module.exports = function generate_patternRequired(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 $key = 'key' + $lvl,
  14.     $matched = 'patternMatched' + $lvl,
  15.     $closingBraces = '',
  16.     $ownProperties = it.opts.ownProperties;
  17.   out += 'var ' + ($valid) + ' = true;';
  18.   var arr1 = $schema;
  19.   if (arr1) {
  20.     var $pProperty, i1 = -1,
  21.       l1 = arr1.length - 1;
  22.     while (i1 < l1) {
  23.       $pProperty = arr1[i1 += 1];
  24.       out += ' var ' + ($matched) + ' = false; for (var ' + ($key) + ' in ' + ($data) + ') {  ';
  25.       if ($ownProperties) {
  26.         out += ' if (!Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($key) + ')) continue; ';
  27.       }
  28.       out += ' ' + ($matched) + ' = ' + (it.usePattern($pProperty)) + '.test(' + ($key) + '); if (' + ($matched) + ') break; } ';
  29.       var $missingPattern = it.util.escapeQuotes($pProperty);
  30.       out += ' if (!' + ($matched) + ') { ' + ($valid) + ' = false;  var err =   '; /* istanbul ignore else */
  31.       if (it.createErrors !== false) {
  32.         out += ' { keyword: \'' + ($errorKeyword || 'patternRequired') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingPattern: \'' + ($missingPattern) + '\' } ';
  33.         if (it.opts.messages !== false) {
  34.           out += ' , message: \'should have property matching pattern \\\'' + ($missingPattern) + '\\\'\' ';
  35.         }
  36.         if (it.opts.verbose) {
  37.           out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  38.         }
  39.         out += ' } ';
  40.       } else {
  41.         out += ' {} ';
  42.       }
  43.       out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; }   ';
  44.       if ($breakOnError) {
  45.         $closingBraces += '}';
  46.         out += ' else { ';
  47.       }
  48.     }
  49.   }
  50.   out += '' + ($closingBraces);
  51.   return out;
  52. }
  53.  
downloadpatternRequired.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