BVB Source Codes

reactide Show _limitLength.js Source code

Return Download reactide: download _limitLength.js Source code - Download reactide Source code - Type:.js
  1. 'use strict';
  2. module.exports = function generate__limitLength(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 $op = $keyword == 'maxLength' ? '>' : '<';
  21.   out += 'if ( ';
  22.   if ($isData) {
  23.     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
  24.   }
  25.   if (it.opts.unicode === false) {
  26.     out += ' ' + ($data) + '.length ';
  27.   } else {
  28.     out += ' ucs2length(' + ($data) + ') ';
  29.   }
  30.   out += ' ' + ($op) + ' ' + ($schemaValue) + ') { ';
  31.   var $errorKeyword = $keyword;
  32.   var $$outStack = $$outStack || [];
  33.   $$outStack.push(out);
  34.   out = ''; /* istanbul ignore else */
  35.   if (it.createErrors !== false) {
  36.     out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
  37.     if (it.opts.messages !== false) {
  38.       out += ' , message: \'should NOT be ';
  39.       if ($keyword == 'maxLength') {
  40.         out += 'longer';
  41.       } else {
  42.         out += 'shorter';
  43.       }
  44.       out += ' than ';
  45.       if ($isData) {
  46.         out += '\' + ' + ($schemaValue) + ' + \'';
  47.       } else {
  48.         out += '' + ($schema);
  49.       }
  50.       out += ' characters\' ';
  51.     }
  52.     if (it.opts.verbose) {
  53.       out += ' , schema:  ';
  54.       if ($isData) {
  55.         out += 'validate.schema' + ($schemaPath);
  56.       } else {
  57.         out += '' + ($schema);
  58.       }
  59.       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
  60.     }
  61.     out += ' } ';
  62.   } else {
  63.     out += ' {} ';
  64.   }
  65.   var __err = out;
  66.   out = $$outStack.pop();
  67.   if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
  68.     if (it.async) {
  69.       out += ' throw new ValidationError([' + (__err) + ']); ';
  70.     } else {
  71.       out += ' validate.errors = [' + (__err) + ']; return false; ';
  72.     }
  73.   } else {
  74.     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  75.   }
  76.   out += '} ';
  77.   if ($breakOnError) {
  78.     out += ' else { ';
  79.   }
  80.   return out;
  81. }
  82.  
download_limitLength.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