BVB Source Codes

reactide Show pattern.js Source code

Return Download reactide: download pattern.js Source code - Download reactide Source code - Type:.js
  1. 'use strict';
  2. module.exports = function generate_pattern(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 $isData = it.opts.v5 && $schema && $schema.$data,
  13.     $schemaValue;
  14.   if ($isData) {
  15.     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
  16.     $schemaValue = 'schema' + $lvl;
  17.   } else {
  18.     $schemaValue = $schema;
  19.   }
  20.   var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema);
  21.   out += 'if ( ';
  22.   if ($isData) {
  23.     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || ';
  24.   }
  25.   out += ' !' + ($regexp) + '.test(' + ($data) + ') ) {   ';
  26.   var $$outStack = $$outStack || [];
  27.   $$outStack.push(out);
  28.   out = ''; /* istanbul ignore else */
  29.   if (it.createErrors !== false) {
  30.     out += ' { keyword: \'' + ($errorKeyword || 'pattern') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { pattern:  ';
  31.     if ($isData) {
  32.       out += '' + ($schemaValue);
  33.     } else {
  34.       out += '' + (it.util.toQuotedString($schema));
  35.     }
  36.     out += '  } ';
  37.     if (it.opts.messages !== false) {
  38.       out += ' , message: \'should match pattern "';
  39.       if ($isData) {
  40.         out += '\' + ' + ($schemaValue) + ' + \'';
  41.       } else {
  42.         out += '' + (it.util.escapeQuotes($schema));
  43.       }
  44.       out += '"\' ';
  45.     }
  46.     if (it.opts.verbose) {
  47.       out += ' , schema:  ';
  48.       if ($isData) {
  49.         out += 'validate.schema' + ($schemaPath);
  50.       } else {
  51.         out += '' + (it.util.toQuotedString($schema));
  52.       }
  53.       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  54.     }
  55.     out += ' } ';
  56.   } else {
  57.     out += ' {} ';
  58.   }
  59.   var __err = out;
  60.   out = $$outStack.pop();
  61.   if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  62.     if (it.async) {
  63.       out += ' throw new ValidationError([' + (__err) + ']); ';
  64.     } else {
  65.       out += ' validate.errors = [' + (__err) + ']; return false; ';
  66.     }
  67.   } else {
  68.     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  69.   }
  70.   out += '} ';
  71.   if ($breakOnError) {
  72.     out += ' else { ';
  73.   }
  74.   return out;
  75. }
  76.  
downloadpattern.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