update socials section
This commit is contained in:
		
							
								
								
									
										3
									
								
								node_modules/ajv/lib/dotjs/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								node_modules/ajv/lib/dotjs/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| These files are compiled dot templates from dot folder. | ||||
|  | ||||
| Do NOT edit them directly, edit the templates and run `npm run build` from main ajv folder. | ||||
							
								
								
									
										163
									
								
								node_modules/ajv/lib/dotjs/_limit.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										163
									
								
								node_modules/ajv/lib/dotjs/_limit.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,163 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate__limit(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $errorKeyword; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   var $isMax = $keyword == 'maximum', | ||||
|     $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum', | ||||
|     $schemaExcl = it.schema[$exclusiveKeyword], | ||||
|     $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data, | ||||
|     $op = $isMax ? '<' : '>', | ||||
|     $notOp = $isMax ? '>' : '<', | ||||
|     $errorKeyword = undefined; | ||||
|   if (!($isData || typeof $schema == 'number' || $schema === undefined)) { | ||||
|     throw new Error($keyword + ' must be number'); | ||||
|   } | ||||
|   if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) { | ||||
|     throw new Error($exclusiveKeyword + ' must be number or boolean'); | ||||
|   } | ||||
|   if ($isDataExcl) { | ||||
|     var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr), | ||||
|       $exclusive = 'exclusive' + $lvl, | ||||
|       $exclType = 'exclType' + $lvl, | ||||
|       $exclIsNumber = 'exclIsNumber' + $lvl, | ||||
|       $opExpr = 'op' + $lvl, | ||||
|       $opStr = '\' + ' + $opExpr + ' + \''; | ||||
|     out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; '; | ||||
|     $schemaValueExcl = 'schemaExcl' + $lvl; | ||||
|     out += ' var ' + ($exclusive) + '; var ' + ($exclType) + ' = typeof ' + ($schemaValueExcl) + '; if (' + ($exclType) + ' != \'boolean\' && ' + ($exclType) + ' != \'undefined\' && ' + ($exclType) + ' != \'number\') { '; | ||||
|     var $errorKeyword = $exclusiveKeyword; | ||||
|     var $$outStack = $$outStack || []; | ||||
|     $$outStack.push(out); | ||||
|     out = ''; /* istanbul ignore else */ | ||||
|     if (it.createErrors !== false) { | ||||
|       out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; | ||||
|       if (it.opts.messages !== false) { | ||||
|         out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' '; | ||||
|       } | ||||
|       if (it.opts.verbose) { | ||||
|         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|       } | ||||
|       out += ' } '; | ||||
|     } else { | ||||
|       out += ' {} '; | ||||
|     } | ||||
|     var __err = out; | ||||
|     out = $$outStack.pop(); | ||||
|     if (!it.compositeRule && $breakOnError) { | ||||
|       /* istanbul ignore if */ | ||||
|       if (it.async) { | ||||
|         out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|       } else { | ||||
|         out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|       } | ||||
|     } else { | ||||
|       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|     } | ||||
|     out += ' } else if ( '; | ||||
|     if ($isData) { | ||||
|       out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; | ||||
|     } | ||||
|     out += ' ' + ($exclType) + ' == \'number\' ? ( (' + ($exclusive) + ' = ' + ($schemaValue) + ' === undefined || ' + ($schemaValueExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ') ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValueExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) : ( (' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true) ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValue) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\'; '; | ||||
|     if ($schema === undefined) { | ||||
|       $errorKeyword = $exclusiveKeyword; | ||||
|       $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword; | ||||
|       $schemaValue = $schemaValueExcl; | ||||
|       $isData = $isDataExcl; | ||||
|     } | ||||
|   } else { | ||||
|     var $exclIsNumber = typeof $schemaExcl == 'number', | ||||
|       $opStr = $op; | ||||
|     if ($exclIsNumber && $isData) { | ||||
|       var $opExpr = '\'' + $opStr + '\''; | ||||
|       out += ' if ( '; | ||||
|       if ($isData) { | ||||
|         out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; | ||||
|       } | ||||
|       out += ' ( ' + ($schemaValue) + ' === undefined || ' + ($schemaExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ' ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { '; | ||||
|     } else { | ||||
|       if ($exclIsNumber && $schema === undefined) { | ||||
|         $exclusive = true; | ||||
|         $errorKeyword = $exclusiveKeyword; | ||||
|         $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword; | ||||
|         $schemaValue = $schemaExcl; | ||||
|         $notOp += '='; | ||||
|       } else { | ||||
|         if ($exclIsNumber) $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema); | ||||
|         if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) { | ||||
|           $exclusive = true; | ||||
|           $errorKeyword = $exclusiveKeyword; | ||||
|           $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword; | ||||
|           $notOp += '='; | ||||
|         } else { | ||||
|           $exclusive = false; | ||||
|           $opStr += '='; | ||||
|         } | ||||
|       } | ||||
|       var $opExpr = '\'' + $opStr + '\''; | ||||
|       out += ' if ( '; | ||||
|       if ($isData) { | ||||
|         out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; | ||||
|       } | ||||
|       out += ' ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' || ' + ($data) + ' !== ' + ($data) + ') { '; | ||||
|     } | ||||
|   } | ||||
|   $errorKeyword = $errorKeyword || $keyword; | ||||
|   var $$outStack = $$outStack || []; | ||||
|   $$outStack.push(out); | ||||
|   out = ''; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ' + ($schemaValue) + ', exclusive: ' + ($exclusive) + ' } '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should be ' + ($opStr) + ' '; | ||||
|       if ($isData) { | ||||
|         out += '\' + ' + ($schemaValue); | ||||
|       } else { | ||||
|         out += '' + ($schemaValue) + '\''; | ||||
|       } | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema:  '; | ||||
|       if ($isData) { | ||||
|         out += 'validate.schema' + ($schemaPath); | ||||
|       } else { | ||||
|         out += '' + ($schema); | ||||
|       } | ||||
|       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   var __err = out; | ||||
|   out = $$outStack.pop(); | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   } | ||||
|   out += ' } '; | ||||
|   if ($breakOnError) { | ||||
|     out += ' else { '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										80
									
								
								node_modules/ajv/lib/dotjs/_limitItems.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								node_modules/ajv/lib/dotjs/_limitItems.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,80 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate__limitItems(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $errorKeyword; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   if (!($isData || typeof $schema == 'number')) { | ||||
|     throw new Error($keyword + ' must be number'); | ||||
|   } | ||||
|   var $op = $keyword == 'maxItems' ? '>' : '<'; | ||||
|   out += 'if ( '; | ||||
|   if ($isData) { | ||||
|     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; | ||||
|   } | ||||
|   out += ' ' + ($data) + '.length ' + ($op) + ' ' + ($schemaValue) + ') { '; | ||||
|   var $errorKeyword = $keyword; | ||||
|   var $$outStack = $$outStack || []; | ||||
|   $$outStack.push(out); | ||||
|   out = ''; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ($errorKeyword || '_limitItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should NOT have '; | ||||
|       if ($keyword == 'maxItems') { | ||||
|         out += 'more'; | ||||
|       } else { | ||||
|         out += 'fewer'; | ||||
|       } | ||||
|       out += ' than '; | ||||
|       if ($isData) { | ||||
|         out += '\' + ' + ($schemaValue) + ' + \''; | ||||
|       } else { | ||||
|         out += '' + ($schema); | ||||
|       } | ||||
|       out += ' items\' '; | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema:  '; | ||||
|       if ($isData) { | ||||
|         out += 'validate.schema' + ($schemaPath); | ||||
|       } else { | ||||
|         out += '' + ($schema); | ||||
|       } | ||||
|       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   var __err = out; | ||||
|   out = $$outStack.pop(); | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   } | ||||
|   out += '} '; | ||||
|   if ($breakOnError) { | ||||
|     out += ' else { '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										85
									
								
								node_modules/ajv/lib/dotjs/_limitLength.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								node_modules/ajv/lib/dotjs/_limitLength.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,85 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate__limitLength(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $errorKeyword; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   if (!($isData || typeof $schema == 'number')) { | ||||
|     throw new Error($keyword + ' must be number'); | ||||
|   } | ||||
|   var $op = $keyword == 'maxLength' ? '>' : '<'; | ||||
|   out += 'if ( '; | ||||
|   if ($isData) { | ||||
|     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; | ||||
|   } | ||||
|   if (it.opts.unicode === false) { | ||||
|     out += ' ' + ($data) + '.length '; | ||||
|   } else { | ||||
|     out += ' ucs2length(' + ($data) + ') '; | ||||
|   } | ||||
|   out += ' ' + ($op) + ' ' + ($schemaValue) + ') { '; | ||||
|   var $errorKeyword = $keyword; | ||||
|   var $$outStack = $$outStack || []; | ||||
|   $$outStack.push(out); | ||||
|   out = ''; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should NOT be '; | ||||
|       if ($keyword == 'maxLength') { | ||||
|         out += 'longer'; | ||||
|       } else { | ||||
|         out += 'shorter'; | ||||
|       } | ||||
|       out += ' than '; | ||||
|       if ($isData) { | ||||
|         out += '\' + ' + ($schemaValue) + ' + \''; | ||||
|       } else { | ||||
|         out += '' + ($schema); | ||||
|       } | ||||
|       out += ' characters\' '; | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema:  '; | ||||
|       if ($isData) { | ||||
|         out += 'validate.schema' + ($schemaPath); | ||||
|       } else { | ||||
|         out += '' + ($schema); | ||||
|       } | ||||
|       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   var __err = out; | ||||
|   out = $$outStack.pop(); | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   } | ||||
|   out += '} '; | ||||
|   if ($breakOnError) { | ||||
|     out += ' else { '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										80
									
								
								node_modules/ajv/lib/dotjs/_limitProperties.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								node_modules/ajv/lib/dotjs/_limitProperties.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,80 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate__limitProperties(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $errorKeyword; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   if (!($isData || typeof $schema == 'number')) { | ||||
|     throw new Error($keyword + ' must be number'); | ||||
|   } | ||||
|   var $op = $keyword == 'maxProperties' ? '>' : '<'; | ||||
|   out += 'if ( '; | ||||
|   if ($isData) { | ||||
|     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; | ||||
|   } | ||||
|   out += ' Object.keys(' + ($data) + ').length ' + ($op) + ' ' + ($schemaValue) + ') { '; | ||||
|   var $errorKeyword = $keyword; | ||||
|   var $$outStack = $$outStack || []; | ||||
|   $$outStack.push(out); | ||||
|   out = ''; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ($errorKeyword || '_limitProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should NOT have '; | ||||
|       if ($keyword == 'maxProperties') { | ||||
|         out += 'more'; | ||||
|       } else { | ||||
|         out += 'fewer'; | ||||
|       } | ||||
|       out += ' than '; | ||||
|       if ($isData) { | ||||
|         out += '\' + ' + ($schemaValue) + ' + \''; | ||||
|       } else { | ||||
|         out += '' + ($schema); | ||||
|       } | ||||
|       out += ' properties\' '; | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema:  '; | ||||
|       if ($isData) { | ||||
|         out += 'validate.schema' + ($schemaPath); | ||||
|       } else { | ||||
|         out += '' + ($schema); | ||||
|       } | ||||
|       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   var __err = out; | ||||
|   out = $$outStack.pop(); | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   } | ||||
|   out += '} '; | ||||
|   if ($breakOnError) { | ||||
|     out += ' else { '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										42
									
								
								node_modules/ajv/lib/dotjs/allOf.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								node_modules/ajv/lib/dotjs/allOf.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_allOf(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $it = it.util.copy(it); | ||||
|   var $closingBraces = ''; | ||||
|   $it.level++; | ||||
|   var $nextValid = 'valid' + $it.level; | ||||
|   var $currentBaseId = $it.baseId, | ||||
|     $allSchemasEmpty = true; | ||||
|   var arr1 = $schema; | ||||
|   if (arr1) { | ||||
|     var $sch, $i = -1, | ||||
|       l1 = arr1.length - 1; | ||||
|     while ($i < l1) { | ||||
|       $sch = arr1[$i += 1]; | ||||
|       if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { | ||||
|         $allSchemasEmpty = false; | ||||
|         $it.schema = $sch; | ||||
|         $it.schemaPath = $schemaPath + '[' + $i + ']'; | ||||
|         $it.errSchemaPath = $errSchemaPath + '/' + $i; | ||||
|         out += '  ' + (it.validate($it)) + ' '; | ||||
|         $it.baseId = $currentBaseId; | ||||
|         if ($breakOnError) { | ||||
|           out += ' if (' + ($nextValid) + ') { '; | ||||
|           $closingBraces += '}'; | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   if ($breakOnError) { | ||||
|     if ($allSchemasEmpty) { | ||||
|       out += ' if (true) { '; | ||||
|     } else { | ||||
|       out += ' ' + ($closingBraces.slice(0, -1)) + ' '; | ||||
|     } | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										73
									
								
								node_modules/ajv/lib/dotjs/anyOf.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								node_modules/ajv/lib/dotjs/anyOf.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_anyOf(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $errs = 'errs__' + $lvl; | ||||
|   var $it = it.util.copy(it); | ||||
|   var $closingBraces = ''; | ||||
|   $it.level++; | ||||
|   var $nextValid = 'valid' + $it.level; | ||||
|   var $noEmptySchema = $schema.every(function($sch) { | ||||
|     return (it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)); | ||||
|   }); | ||||
|   if ($noEmptySchema) { | ||||
|     var $currentBaseId = $it.baseId; | ||||
|     out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = false;  '; | ||||
|     var $wasComposite = it.compositeRule; | ||||
|     it.compositeRule = $it.compositeRule = true; | ||||
|     var arr1 = $schema; | ||||
|     if (arr1) { | ||||
|       var $sch, $i = -1, | ||||
|         l1 = arr1.length - 1; | ||||
|       while ($i < l1) { | ||||
|         $sch = arr1[$i += 1]; | ||||
|         $it.schema = $sch; | ||||
|         $it.schemaPath = $schemaPath + '[' + $i + ']'; | ||||
|         $it.errSchemaPath = $errSchemaPath + '/' + $i; | ||||
|         out += '  ' + (it.validate($it)) + ' '; | ||||
|         $it.baseId = $currentBaseId; | ||||
|         out += ' ' + ($valid) + ' = ' + ($valid) + ' || ' + ($nextValid) + '; if (!' + ($valid) + ') { '; | ||||
|         $closingBraces += '}'; | ||||
|       } | ||||
|     } | ||||
|     it.compositeRule = $it.compositeRule = $wasComposite; | ||||
|     out += ' ' + ($closingBraces) + ' if (!' + ($valid) + ') {   var err =   '; /* istanbul ignore else */ | ||||
|     if (it.createErrors !== false) { | ||||
|       out += ' { keyword: \'' + ('anyOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; | ||||
|       if (it.opts.messages !== false) { | ||||
|         out += ' , message: \'should match some schema in anyOf\' '; | ||||
|       } | ||||
|       if (it.opts.verbose) { | ||||
|         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|       } | ||||
|       out += ' } '; | ||||
|     } else { | ||||
|       out += ' {} '; | ||||
|     } | ||||
|     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|     if (!it.compositeRule && $breakOnError) { | ||||
|       /* istanbul ignore if */ | ||||
|       if (it.async) { | ||||
|         out += ' throw new ValidationError(vErrors); '; | ||||
|       } else { | ||||
|         out += ' validate.errors = vErrors; return false; '; | ||||
|       } | ||||
|     } | ||||
|     out += ' } else {  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } '; | ||||
|     if (it.opts.allErrors) { | ||||
|       out += ' } '; | ||||
|     } | ||||
|   } else { | ||||
|     if ($breakOnError) { | ||||
|       out += ' if (true) { '; | ||||
|     } | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										14
									
								
								node_modules/ajv/lib/dotjs/comment.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								node_modules/ajv/lib/dotjs/comment.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_comment(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $comment = it.util.toQuotedString($schema); | ||||
|   if (it.opts.$comment === true) { | ||||
|     out += ' console.log(' + ($comment) + ');'; | ||||
|   } else if (typeof it.opts.$comment == 'function') { | ||||
|     out += ' self._opts.$comment(' + ($comment) + ', ' + (it.util.toQuotedString($errSchemaPath)) + ', validate.root.schema);'; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										56
									
								
								node_modules/ajv/lib/dotjs/const.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								node_modules/ajv/lib/dotjs/const.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_const(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   if (!$isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = validate.schema' + ($schemaPath) + ';'; | ||||
|   } | ||||
|   out += 'var ' + ($valid) + ' = equal(' + ($data) + ', schema' + ($lvl) + '); if (!' + ($valid) + ') {   '; | ||||
|   var $$outStack = $$outStack || []; | ||||
|   $$outStack.push(out); | ||||
|   out = ''; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ('const') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValue: schema' + ($lvl) + ' } '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should be equal to constant\' '; | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   var __err = out; | ||||
|   out = $$outStack.pop(); | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   } | ||||
|   out += ' }'; | ||||
|   if ($breakOnError) { | ||||
|     out += ' else { '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										81
									
								
								node_modules/ajv/lib/dotjs/contains.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								node_modules/ajv/lib/dotjs/contains.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,81 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_contains(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $errs = 'errs__' + $lvl; | ||||
|   var $it = it.util.copy(it); | ||||
|   var $closingBraces = ''; | ||||
|   $it.level++; | ||||
|   var $nextValid = 'valid' + $it.level; | ||||
|   var $idx = 'i' + $lvl, | ||||
|     $dataNxt = $it.dataLevel = it.dataLevel + 1, | ||||
|     $nextData = 'data' + $dataNxt, | ||||
|     $currentBaseId = it.baseId, | ||||
|     $nonEmptySchema = (it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all)); | ||||
|   out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';'; | ||||
|   if ($nonEmptySchema) { | ||||
|     var $wasComposite = it.compositeRule; | ||||
|     it.compositeRule = $it.compositeRule = true; | ||||
|     $it.schema = $schema; | ||||
|     $it.schemaPath = $schemaPath; | ||||
|     $it.errSchemaPath = $errSchemaPath; | ||||
|     out += ' var ' + ($nextValid) + ' = false; for (var ' + ($idx) + ' = 0; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { '; | ||||
|     $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true); | ||||
|     var $passData = $data + '[' + $idx + ']'; | ||||
|     $it.dataPathArr[$dataNxt] = $idx; | ||||
|     var $code = it.validate($it); | ||||
|     $it.baseId = $currentBaseId; | ||||
|     if (it.util.varOccurences($code, $nextData) < 2) { | ||||
|       out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; | ||||
|     } else { | ||||
|       out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; | ||||
|     } | ||||
|     out += ' if (' + ($nextValid) + ') break; }  '; | ||||
|     it.compositeRule = $it.compositeRule = $wasComposite; | ||||
|     out += ' ' + ($closingBraces) + ' if (!' + ($nextValid) + ') {'; | ||||
|   } else { | ||||
|     out += ' if (' + ($data) + '.length == 0) {'; | ||||
|   } | ||||
|   var $$outStack = $$outStack || []; | ||||
|   $$outStack.push(out); | ||||
|   out = ''; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ('contains') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should contain a valid item\' '; | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   var __err = out; | ||||
|   out = $$outStack.pop(); | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   } | ||||
|   out += ' } else { '; | ||||
|   if ($nonEmptySchema) { | ||||
|     out += '  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } '; | ||||
|   } | ||||
|   if (it.opts.allErrors) { | ||||
|     out += ' } '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										228
									
								
								node_modules/ajv/lib/dotjs/custom.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										228
									
								
								node_modules/ajv/lib/dotjs/custom.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,228 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_custom(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $errorKeyword; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $errs = 'errs__' + $lvl; | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   var $rule = this, | ||||
|     $definition = 'definition' + $lvl, | ||||
|     $rDef = $rule.definition, | ||||
|     $closingBraces = ''; | ||||
|   var $compile, $inline, $macro, $ruleValidate, $validateCode; | ||||
|   if ($isData && $rDef.$data) { | ||||
|     $validateCode = 'keywordValidate' + $lvl; | ||||
|     var $validateSchema = $rDef.validateSchema; | ||||
|     out += ' var ' + ($definition) + ' = RULES.custom[\'' + ($keyword) + '\'].definition; var ' + ($validateCode) + ' = ' + ($definition) + '.validate;'; | ||||
|   } else { | ||||
|     $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it); | ||||
|     if (!$ruleValidate) return; | ||||
|     $schemaValue = 'validate.schema' + $schemaPath; | ||||
|     $validateCode = $ruleValidate.code; | ||||
|     $compile = $rDef.compile; | ||||
|     $inline = $rDef.inline; | ||||
|     $macro = $rDef.macro; | ||||
|   } | ||||
|   var $ruleErrs = $validateCode + '.errors', | ||||
|     $i = 'i' + $lvl, | ||||
|     $ruleErr = 'ruleErr' + $lvl, | ||||
|     $asyncKeyword = $rDef.async; | ||||
|   if ($asyncKeyword && !it.async) throw new Error('async keyword in sync schema'); | ||||
|   if (!($inline || $macro)) { | ||||
|     out += '' + ($ruleErrs) + ' = null;'; | ||||
|   } | ||||
|   out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';'; | ||||
|   if ($isData && $rDef.$data) { | ||||
|     $closingBraces += '}'; | ||||
|     out += ' if (' + ($schemaValue) + ' === undefined) { ' + ($valid) + ' = true; } else { '; | ||||
|     if ($validateSchema) { | ||||
|       $closingBraces += '}'; | ||||
|       out += ' ' + ($valid) + ' = ' + ($definition) + '.validateSchema(' + ($schemaValue) + '); if (' + ($valid) + ') { '; | ||||
|     } | ||||
|   } | ||||
|   if ($inline) { | ||||
|     if ($rDef.statements) { | ||||
|       out += ' ' + ($ruleValidate.validate) + ' '; | ||||
|     } else { | ||||
|       out += ' ' + ($valid) + ' = ' + ($ruleValidate.validate) + '; '; | ||||
|     } | ||||
|   } else if ($macro) { | ||||
|     var $it = it.util.copy(it); | ||||
|     var $closingBraces = ''; | ||||
|     $it.level++; | ||||
|     var $nextValid = 'valid' + $it.level; | ||||
|     $it.schema = $ruleValidate.validate; | ||||
|     $it.schemaPath = ''; | ||||
|     var $wasComposite = it.compositeRule; | ||||
|     it.compositeRule = $it.compositeRule = true; | ||||
|     var $code = it.validate($it).replace(/validate\.schema/g, $validateCode); | ||||
|     it.compositeRule = $it.compositeRule = $wasComposite; | ||||
|     out += ' ' + ($code); | ||||
|   } else { | ||||
|     var $$outStack = $$outStack || []; | ||||
|     $$outStack.push(out); | ||||
|     out = ''; | ||||
|     out += '  ' + ($validateCode) + '.call( '; | ||||
|     if (it.opts.passContext) { | ||||
|       out += 'this'; | ||||
|     } else { | ||||
|       out += 'self'; | ||||
|     } | ||||
|     if ($compile || $rDef.schema === false) { | ||||
|       out += ' , ' + ($data) + ' '; | ||||
|     } else { | ||||
|       out += ' , ' + ($schemaValue) + ' , ' + ($data) + ' , validate.schema' + (it.schemaPath) + ' '; | ||||
|     } | ||||
|     out += ' , (dataPath || \'\')'; | ||||
|     if (it.errorPath != '""') { | ||||
|       out += ' + ' + (it.errorPath); | ||||
|     } | ||||
|     var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData', | ||||
|       $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty'; | ||||
|     out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ' , rootData )  '; | ||||
|     var def_callRuleValidate = out; | ||||
|     out = $$outStack.pop(); | ||||
|     if ($rDef.errors === false) { | ||||
|       out += ' ' + ($valid) + ' = '; | ||||
|       if ($asyncKeyword) { | ||||
|         out += 'await '; | ||||
|       } | ||||
|       out += '' + (def_callRuleValidate) + '; '; | ||||
|     } else { | ||||
|       if ($asyncKeyword) { | ||||
|         $ruleErrs = 'customErrors' + $lvl; | ||||
|         out += ' var ' + ($ruleErrs) + ' = null; try { ' + ($valid) + ' = await ' + (def_callRuleValidate) + '; } catch (e) { ' + ($valid) + ' = false; if (e instanceof ValidationError) ' + ($ruleErrs) + ' = e.errors; else throw e; } '; | ||||
|       } else { | ||||
|         out += ' ' + ($ruleErrs) + ' = null; ' + ($valid) + ' = ' + (def_callRuleValidate) + '; '; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   if ($rDef.modifying) { | ||||
|     out += ' if (' + ($parentData) + ') ' + ($data) + ' = ' + ($parentData) + '[' + ($parentDataProperty) + '];'; | ||||
|   } | ||||
|   out += '' + ($closingBraces); | ||||
|   if ($rDef.valid) { | ||||
|     if ($breakOnError) { | ||||
|       out += ' if (true) { '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' if ( '; | ||||
|     if ($rDef.valid === undefined) { | ||||
|       out += ' !'; | ||||
|       if ($macro) { | ||||
|         out += '' + ($nextValid); | ||||
|       } else { | ||||
|         out += '' + ($valid); | ||||
|       } | ||||
|     } else { | ||||
|       out += ' ' + (!$rDef.valid) + ' '; | ||||
|     } | ||||
|     out += ') { '; | ||||
|     $errorKeyword = $rule.keyword; | ||||
|     var $$outStack = $$outStack || []; | ||||
|     $$outStack.push(out); | ||||
|     out = ''; | ||||
|     var $$outStack = $$outStack || []; | ||||
|     $$outStack.push(out); | ||||
|     out = ''; /* istanbul ignore else */ | ||||
|     if (it.createErrors !== false) { | ||||
|       out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } '; | ||||
|       if (it.opts.messages !== false) { | ||||
|         out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' '; | ||||
|       } | ||||
|       if (it.opts.verbose) { | ||||
|         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|       } | ||||
|       out += ' } '; | ||||
|     } else { | ||||
|       out += ' {} '; | ||||
|     } | ||||
|     var __err = out; | ||||
|     out = $$outStack.pop(); | ||||
|     if (!it.compositeRule && $breakOnError) { | ||||
|       /* istanbul ignore if */ | ||||
|       if (it.async) { | ||||
|         out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|       } else { | ||||
|         out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|       } | ||||
|     } else { | ||||
|       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|     } | ||||
|     var def_customError = out; | ||||
|     out = $$outStack.pop(); | ||||
|     if ($inline) { | ||||
|       if ($rDef.errors) { | ||||
|         if ($rDef.errors != 'full') { | ||||
|           out += '  for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; if (' + ($ruleErr) + '.schemaPath === undefined) { ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; } '; | ||||
|           if (it.opts.verbose) { | ||||
|             out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; '; | ||||
|           } | ||||
|           out += ' } '; | ||||
|         } | ||||
|       } else { | ||||
|         if ($rDef.errors === false) { | ||||
|           out += ' ' + (def_customError) + ' '; | ||||
|         } else { | ||||
|           out += ' if (' + ($errs) + ' == errors) { ' + (def_customError) + ' } else {  for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; if (' + ($ruleErr) + '.schemaPath === undefined) { ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; } '; | ||||
|           if (it.opts.verbose) { | ||||
|             out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; '; | ||||
|           } | ||||
|           out += ' } } '; | ||||
|         } | ||||
|       } | ||||
|     } else if ($macro) { | ||||
|       out += '   var err =   '; /* istanbul ignore else */ | ||||
|       if (it.createErrors !== false) { | ||||
|         out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } '; | ||||
|         if (it.opts.messages !== false) { | ||||
|           out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' '; | ||||
|         } | ||||
|         if (it.opts.verbose) { | ||||
|           out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|         } | ||||
|         out += ' } '; | ||||
|       } else { | ||||
|         out += ' {} '; | ||||
|       } | ||||
|       out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|       if (!it.compositeRule && $breakOnError) { | ||||
|         /* istanbul ignore if */ | ||||
|         if (it.async) { | ||||
|           out += ' throw new ValidationError(vErrors); '; | ||||
|         } else { | ||||
|           out += ' validate.errors = vErrors; return false; '; | ||||
|         } | ||||
|       } | ||||
|     } else { | ||||
|       if ($rDef.errors === false) { | ||||
|         out += ' ' + (def_customError) + ' '; | ||||
|       } else { | ||||
|         out += ' if (Array.isArray(' + ($ruleErrs) + ')) { if (vErrors === null) vErrors = ' + ($ruleErrs) + '; else vErrors = vErrors.concat(' + ($ruleErrs) + '); errors = vErrors.length;  for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + ';  ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '";  '; | ||||
|         if (it.opts.verbose) { | ||||
|           out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; '; | ||||
|         } | ||||
|         out += ' } } else { ' + (def_customError) + ' } '; | ||||
|       } | ||||
|     } | ||||
|     out += ' } '; | ||||
|     if ($breakOnError) { | ||||
|       out += ' else { '; | ||||
|     } | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										168
									
								
								node_modules/ajv/lib/dotjs/dependencies.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										168
									
								
								node_modules/ajv/lib/dotjs/dependencies.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,168 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_dependencies(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $errs = 'errs__' + $lvl; | ||||
|   var $it = it.util.copy(it); | ||||
|   var $closingBraces = ''; | ||||
|   $it.level++; | ||||
|   var $nextValid = 'valid' + $it.level; | ||||
|   var $schemaDeps = {}, | ||||
|     $propertyDeps = {}, | ||||
|     $ownProperties = it.opts.ownProperties; | ||||
|   for ($property in $schema) { | ||||
|     if ($property == '__proto__') continue; | ||||
|     var $sch = $schema[$property]; | ||||
|     var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps; | ||||
|     $deps[$property] = $sch; | ||||
|   } | ||||
|   out += 'var ' + ($errs) + ' = errors;'; | ||||
|   var $currentErrorPath = it.errorPath; | ||||
|   out += 'var missing' + ($lvl) + ';'; | ||||
|   for (var $property in $propertyDeps) { | ||||
|     $deps = $propertyDeps[$property]; | ||||
|     if ($deps.length) { | ||||
|       out += ' if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined '; | ||||
|       if ($ownProperties) { | ||||
|         out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') '; | ||||
|       } | ||||
|       if ($breakOnError) { | ||||
|         out += ' && ( '; | ||||
|         var arr1 = $deps; | ||||
|         if (arr1) { | ||||
|           var $propertyKey, $i = -1, | ||||
|             l1 = arr1.length - 1; | ||||
|           while ($i < l1) { | ||||
|             $propertyKey = arr1[$i += 1]; | ||||
|             if ($i) { | ||||
|               out += ' || '; | ||||
|             } | ||||
|             var $prop = it.util.getProperty($propertyKey), | ||||
|               $useData = $data + $prop; | ||||
|             out += ' ( ( ' + ($useData) + ' === undefined '; | ||||
|             if ($ownProperties) { | ||||
|               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; | ||||
|             } | ||||
|             out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) '; | ||||
|           } | ||||
|         } | ||||
|         out += ')) {  '; | ||||
|         var $propertyPath = 'missing' + $lvl, | ||||
|           $missingProperty = '\' + ' + $propertyPath + ' + \''; | ||||
|         if (it.opts._errorDataPathProperty) { | ||||
|           it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath; | ||||
|         } | ||||
|         var $$outStack = $$outStack || []; | ||||
|         $$outStack.push(out); | ||||
|         out = ''; /* istanbul ignore else */ | ||||
|         if (it.createErrors !== false) { | ||||
|           out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } '; | ||||
|           if (it.opts.messages !== false) { | ||||
|             out += ' , message: \'should have '; | ||||
|             if ($deps.length == 1) { | ||||
|               out += 'property ' + (it.util.escapeQuotes($deps[0])); | ||||
|             } else { | ||||
|               out += 'properties ' + (it.util.escapeQuotes($deps.join(", "))); | ||||
|             } | ||||
|             out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' '; | ||||
|           } | ||||
|           if (it.opts.verbose) { | ||||
|             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|           } | ||||
|           out += ' } '; | ||||
|         } else { | ||||
|           out += ' {} '; | ||||
|         } | ||||
|         var __err = out; | ||||
|         out = $$outStack.pop(); | ||||
|         if (!it.compositeRule && $breakOnError) { | ||||
|           /* istanbul ignore if */ | ||||
|           if (it.async) { | ||||
|             out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|           } else { | ||||
|             out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|           } | ||||
|         } else { | ||||
|           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|         } | ||||
|       } else { | ||||
|         out += ' ) { '; | ||||
|         var arr2 = $deps; | ||||
|         if (arr2) { | ||||
|           var $propertyKey, i2 = -1, | ||||
|             l2 = arr2.length - 1; | ||||
|           while (i2 < l2) { | ||||
|             $propertyKey = arr2[i2 += 1]; | ||||
|             var $prop = it.util.getProperty($propertyKey), | ||||
|               $missingProperty = it.util.escapeQuotes($propertyKey), | ||||
|               $useData = $data + $prop; | ||||
|             if (it.opts._errorDataPathProperty) { | ||||
|               it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers); | ||||
|             } | ||||
|             out += ' if ( ' + ($useData) + ' === undefined '; | ||||
|             if ($ownProperties) { | ||||
|               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; | ||||
|             } | ||||
|             out += ') {  var err =   '; /* istanbul ignore else */ | ||||
|             if (it.createErrors !== false) { | ||||
|               out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } '; | ||||
|               if (it.opts.messages !== false) { | ||||
|                 out += ' , message: \'should have '; | ||||
|                 if ($deps.length == 1) { | ||||
|                   out += 'property ' + (it.util.escapeQuotes($deps[0])); | ||||
|                 } else { | ||||
|                   out += 'properties ' + (it.util.escapeQuotes($deps.join(", "))); | ||||
|                 } | ||||
|                 out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' '; | ||||
|               } | ||||
|               if (it.opts.verbose) { | ||||
|                 out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|               } | ||||
|               out += ' } '; | ||||
|             } else { | ||||
|               out += ' {} '; | ||||
|             } | ||||
|             out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } '; | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       out += ' }   '; | ||||
|       if ($breakOnError) { | ||||
|         $closingBraces += '}'; | ||||
|         out += ' else { '; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   it.errorPath = $currentErrorPath; | ||||
|   var $currentBaseId = $it.baseId; | ||||
|   for (var $property in $schemaDeps) { | ||||
|     var $sch = $schemaDeps[$property]; | ||||
|     if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { | ||||
|       out += ' ' + ($nextValid) + ' = true; if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined '; | ||||
|       if ($ownProperties) { | ||||
|         out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') '; | ||||
|       } | ||||
|       out += ') { '; | ||||
|       $it.schema = $sch; | ||||
|       $it.schemaPath = $schemaPath + it.util.getProperty($property); | ||||
|       $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property); | ||||
|       out += '  ' + (it.validate($it)) + ' '; | ||||
|       $it.baseId = $currentBaseId; | ||||
|       out += ' }  '; | ||||
|       if ($breakOnError) { | ||||
|         out += ' if (' + ($nextValid) + ') { '; | ||||
|         $closingBraces += '}'; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   if ($breakOnError) { | ||||
|     out += '   ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										66
									
								
								node_modules/ajv/lib/dotjs/enum.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								node_modules/ajv/lib/dotjs/enum.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_enum(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   var $i = 'i' + $lvl, | ||||
|     $vSchema = 'schema' + $lvl; | ||||
|   if (!$isData) { | ||||
|     out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + ';'; | ||||
|   } | ||||
|   out += 'var ' + ($valid) + ';'; | ||||
|   if ($isData) { | ||||
|     out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {'; | ||||
|   } | ||||
|   out += '' + ($valid) + ' = false;for (var ' + ($i) + '=0; ' + ($i) + '<' + ($vSchema) + '.length; ' + ($i) + '++) if (equal(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + '])) { ' + ($valid) + ' = true; break; }'; | ||||
|   if ($isData) { | ||||
|     out += '  }  '; | ||||
|   } | ||||
|   out += ' if (!' + ($valid) + ') {   '; | ||||
|   var $$outStack = $$outStack || []; | ||||
|   $$outStack.push(out); | ||||
|   out = ''; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ('enum') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValues: schema' + ($lvl) + ' } '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should be equal to one of the allowed values\' '; | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   var __err = out; | ||||
|   out = $$outStack.pop(); | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   } | ||||
|   out += ' }'; | ||||
|   if ($breakOnError) { | ||||
|     out += ' else { '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										150
									
								
								node_modules/ajv/lib/dotjs/format.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								node_modules/ajv/lib/dotjs/format.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,150 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_format(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   if (it.opts.format === false) { | ||||
|     if ($breakOnError) { | ||||
|       out += ' if (true) { '; | ||||
|     } | ||||
|     return out; | ||||
|   } | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   var $unknownFormats = it.opts.unknownFormats, | ||||
|     $allowUnknown = Array.isArray($unknownFormats); | ||||
|   if ($isData) { | ||||
|     var $format = 'format' + $lvl, | ||||
|       $isObject = 'isObject' + $lvl, | ||||
|       $formatType = 'formatType' + $lvl; | ||||
|     out += ' var ' + ($format) + ' = formats[' + ($schemaValue) + ']; var ' + ($isObject) + ' = typeof ' + ($format) + ' == \'object\' && !(' + ($format) + ' instanceof RegExp) && ' + ($format) + '.validate; var ' + ($formatType) + ' = ' + ($isObject) + ' && ' + ($format) + '.type || \'string\'; if (' + ($isObject) + ') { '; | ||||
|     if (it.async) { | ||||
|       out += ' var async' + ($lvl) + ' = ' + ($format) + '.async; '; | ||||
|     } | ||||
|     out += ' ' + ($format) + ' = ' + ($format) + '.validate; } if (  '; | ||||
|     if ($isData) { | ||||
|       out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || '; | ||||
|     } | ||||
|     out += ' ('; | ||||
|     if ($unknownFormats != 'ignore') { | ||||
|       out += ' (' + ($schemaValue) + ' && !' + ($format) + ' '; | ||||
|       if ($allowUnknown) { | ||||
|         out += ' && self._opts.unknownFormats.indexOf(' + ($schemaValue) + ') == -1 '; | ||||
|       } | ||||
|       out += ') || '; | ||||
|     } | ||||
|     out += ' (' + ($format) + ' && ' + ($formatType) + ' == \'' + ($ruleType) + '\' && !(typeof ' + ($format) + ' == \'function\' ? '; | ||||
|     if (it.async) { | ||||
|       out += ' (async' + ($lvl) + ' ? await ' + ($format) + '(' + ($data) + ') : ' + ($format) + '(' + ($data) + ')) '; | ||||
|     } else { | ||||
|       out += ' ' + ($format) + '(' + ($data) + ') '; | ||||
|     } | ||||
|     out += ' : ' + ($format) + '.test(' + ($data) + '))))) {'; | ||||
|   } else { | ||||
|     var $format = it.formats[$schema]; | ||||
|     if (!$format) { | ||||
|       if ($unknownFormats == 'ignore') { | ||||
|         it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"'); | ||||
|         if ($breakOnError) { | ||||
|           out += ' if (true) { '; | ||||
|         } | ||||
|         return out; | ||||
|       } else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) { | ||||
|         if ($breakOnError) { | ||||
|           out += ' if (true) { '; | ||||
|         } | ||||
|         return out; | ||||
|       } else { | ||||
|         throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"'); | ||||
|       } | ||||
|     } | ||||
|     var $isObject = typeof $format == 'object' && !($format instanceof RegExp) && $format.validate; | ||||
|     var $formatType = $isObject && $format.type || 'string'; | ||||
|     if ($isObject) { | ||||
|       var $async = $format.async === true; | ||||
|       $format = $format.validate; | ||||
|     } | ||||
|     if ($formatType != $ruleType) { | ||||
|       if ($breakOnError) { | ||||
|         out += ' if (true) { '; | ||||
|       } | ||||
|       return out; | ||||
|     } | ||||
|     if ($async) { | ||||
|       if (!it.async) throw new Error('async format in sync schema'); | ||||
|       var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate'; | ||||
|       out += ' if (!(await ' + ($formatRef) + '(' + ($data) + '))) { '; | ||||
|     } else { | ||||
|       out += ' if (! '; | ||||
|       var $formatRef = 'formats' + it.util.getProperty($schema); | ||||
|       if ($isObject) $formatRef += '.validate'; | ||||
|       if (typeof $format == 'function') { | ||||
|         out += ' ' + ($formatRef) + '(' + ($data) + ') '; | ||||
|       } else { | ||||
|         out += ' ' + ($formatRef) + '.test(' + ($data) + ') '; | ||||
|       } | ||||
|       out += ') { '; | ||||
|     } | ||||
|   } | ||||
|   var $$outStack = $$outStack || []; | ||||
|   $$outStack.push(out); | ||||
|   out = ''; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ('format') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { format:  '; | ||||
|     if ($isData) { | ||||
|       out += '' + ($schemaValue); | ||||
|     } else { | ||||
|       out += '' + (it.util.toQuotedString($schema)); | ||||
|     } | ||||
|     out += '  } '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should match format "'; | ||||
|       if ($isData) { | ||||
|         out += '\' + ' + ($schemaValue) + ' + \''; | ||||
|       } else { | ||||
|         out += '' + (it.util.escapeQuotes($schema)); | ||||
|       } | ||||
|       out += '"\' '; | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema:  '; | ||||
|       if ($isData) { | ||||
|         out += 'validate.schema' + ($schemaPath); | ||||
|       } else { | ||||
|         out += '' + (it.util.toQuotedString($schema)); | ||||
|       } | ||||
|       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   var __err = out; | ||||
|   out = $$outStack.pop(); | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   } | ||||
|   out += ' } '; | ||||
|   if ($breakOnError) { | ||||
|     out += ' else { '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										103
									
								
								node_modules/ajv/lib/dotjs/if.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								node_modules/ajv/lib/dotjs/if.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,103 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_if(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $errs = 'errs__' + $lvl; | ||||
|   var $it = it.util.copy(it); | ||||
|   $it.level++; | ||||
|   var $nextValid = 'valid' + $it.level; | ||||
|   var $thenSch = it.schema['then'], | ||||
|     $elseSch = it.schema['else'], | ||||
|     $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? (typeof $thenSch == 'object' && Object.keys($thenSch).length > 0) || $thenSch === false : it.util.schemaHasRules($thenSch, it.RULES.all)), | ||||
|     $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? (typeof $elseSch == 'object' && Object.keys($elseSch).length > 0) || $elseSch === false : it.util.schemaHasRules($elseSch, it.RULES.all)), | ||||
|     $currentBaseId = $it.baseId; | ||||
|   if ($thenPresent || $elsePresent) { | ||||
|     var $ifClause; | ||||
|     $it.createErrors = false; | ||||
|     $it.schema = $schema; | ||||
|     $it.schemaPath = $schemaPath; | ||||
|     $it.errSchemaPath = $errSchemaPath; | ||||
|     out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = true;  '; | ||||
|     var $wasComposite = it.compositeRule; | ||||
|     it.compositeRule = $it.compositeRule = true; | ||||
|     out += '  ' + (it.validate($it)) + ' '; | ||||
|     $it.baseId = $currentBaseId; | ||||
|     $it.createErrors = true; | ||||
|     out += '  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; }  '; | ||||
|     it.compositeRule = $it.compositeRule = $wasComposite; | ||||
|     if ($thenPresent) { | ||||
|       out += ' if (' + ($nextValid) + ') {  '; | ||||
|       $it.schema = it.schema['then']; | ||||
|       $it.schemaPath = it.schemaPath + '.then'; | ||||
|       $it.errSchemaPath = it.errSchemaPath + '/then'; | ||||
|       out += '  ' + (it.validate($it)) + ' '; | ||||
|       $it.baseId = $currentBaseId; | ||||
|       out += ' ' + ($valid) + ' = ' + ($nextValid) + '; '; | ||||
|       if ($thenPresent && $elsePresent) { | ||||
|         $ifClause = 'ifClause' + $lvl; | ||||
|         out += ' var ' + ($ifClause) + ' = \'then\'; '; | ||||
|       } else { | ||||
|         $ifClause = '\'then\''; | ||||
|       } | ||||
|       out += ' } '; | ||||
|       if ($elsePresent) { | ||||
|         out += ' else { '; | ||||
|       } | ||||
|     } else { | ||||
|       out += ' if (!' + ($nextValid) + ') { '; | ||||
|     } | ||||
|     if ($elsePresent) { | ||||
|       $it.schema = it.schema['else']; | ||||
|       $it.schemaPath = it.schemaPath + '.else'; | ||||
|       $it.errSchemaPath = it.errSchemaPath + '/else'; | ||||
|       out += '  ' + (it.validate($it)) + ' '; | ||||
|       $it.baseId = $currentBaseId; | ||||
|       out += ' ' + ($valid) + ' = ' + ($nextValid) + '; '; | ||||
|       if ($thenPresent && $elsePresent) { | ||||
|         $ifClause = 'ifClause' + $lvl; | ||||
|         out += ' var ' + ($ifClause) + ' = \'else\'; '; | ||||
|       } else { | ||||
|         $ifClause = '\'else\''; | ||||
|       } | ||||
|       out += ' } '; | ||||
|     } | ||||
|     out += ' if (!' + ($valid) + ') {   var err =   '; /* istanbul ignore else */ | ||||
|     if (it.createErrors !== false) { | ||||
|       out += ' { keyword: \'' + ('if') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { failingKeyword: ' + ($ifClause) + ' } '; | ||||
|       if (it.opts.messages !== false) { | ||||
|         out += ' , message: \'should match "\' + ' + ($ifClause) + ' + \'" schema\' '; | ||||
|       } | ||||
|       if (it.opts.verbose) { | ||||
|         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|       } | ||||
|       out += ' } '; | ||||
|     } else { | ||||
|       out += ' {} '; | ||||
|     } | ||||
|     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|     if (!it.compositeRule && $breakOnError) { | ||||
|       /* istanbul ignore if */ | ||||
|       if (it.async) { | ||||
|         out += ' throw new ValidationError(vErrors); '; | ||||
|       } else { | ||||
|         out += ' validate.errors = vErrors; return false; '; | ||||
|       } | ||||
|     } | ||||
|     out += ' }   '; | ||||
|     if ($breakOnError) { | ||||
|       out += ' else { '; | ||||
|     } | ||||
|   } else { | ||||
|     if ($breakOnError) { | ||||
|       out += ' if (true) { '; | ||||
|     } | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										33
									
								
								node_modules/ajv/lib/dotjs/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								node_modules/ajv/lib/dotjs/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| 'use strict'; | ||||
|  | ||||
| //all requires must be explicit because browserify won't work with dynamic requires | ||||
| module.exports = { | ||||
|   '$ref': require('./ref'), | ||||
|   allOf: require('./allOf'), | ||||
|   anyOf: require('./anyOf'), | ||||
|   '$comment': require('./comment'), | ||||
|   const: require('./const'), | ||||
|   contains: require('./contains'), | ||||
|   dependencies: require('./dependencies'), | ||||
|   'enum': require('./enum'), | ||||
|   format: require('./format'), | ||||
|   'if': require('./if'), | ||||
|   items: require('./items'), | ||||
|   maximum: require('./_limit'), | ||||
|   minimum: require('./_limit'), | ||||
|   maxItems: require('./_limitItems'), | ||||
|   minItems: require('./_limitItems'), | ||||
|   maxLength: require('./_limitLength'), | ||||
|   minLength: require('./_limitLength'), | ||||
|   maxProperties: require('./_limitProperties'), | ||||
|   minProperties: require('./_limitProperties'), | ||||
|   multipleOf: require('./multipleOf'), | ||||
|   not: require('./not'), | ||||
|   oneOf: require('./oneOf'), | ||||
|   pattern: require('./pattern'), | ||||
|   properties: require('./properties'), | ||||
|   propertyNames: require('./propertyNames'), | ||||
|   required: require('./required'), | ||||
|   uniqueItems: require('./uniqueItems'), | ||||
|   validate: require('./validate') | ||||
| }; | ||||
							
								
								
									
										140
									
								
								node_modules/ajv/lib/dotjs/items.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								node_modules/ajv/lib/dotjs/items.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,140 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_items(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $errs = 'errs__' + $lvl; | ||||
|   var $it = it.util.copy(it); | ||||
|   var $closingBraces = ''; | ||||
|   $it.level++; | ||||
|   var $nextValid = 'valid' + $it.level; | ||||
|   var $idx = 'i' + $lvl, | ||||
|     $dataNxt = $it.dataLevel = it.dataLevel + 1, | ||||
|     $nextData = 'data' + $dataNxt, | ||||
|     $currentBaseId = it.baseId; | ||||
|   out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';'; | ||||
|   if (Array.isArray($schema)) { | ||||
|     var $additionalItems = it.schema.additionalItems; | ||||
|     if ($additionalItems === false) { | ||||
|       out += ' ' + ($valid) + ' = ' + ($data) + '.length <= ' + ($schema.length) + '; '; | ||||
|       var $currErrSchemaPath = $errSchemaPath; | ||||
|       $errSchemaPath = it.errSchemaPath + '/additionalItems'; | ||||
|       out += '  if (!' + ($valid) + ') {   '; | ||||
|       var $$outStack = $$outStack || []; | ||||
|       $$outStack.push(out); | ||||
|       out = ''; /* istanbul ignore else */ | ||||
|       if (it.createErrors !== false) { | ||||
|         out += ' { keyword: \'' + ('additionalItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schema.length) + ' } '; | ||||
|         if (it.opts.messages !== false) { | ||||
|           out += ' , message: \'should NOT have more than ' + ($schema.length) + ' items\' '; | ||||
|         } | ||||
|         if (it.opts.verbose) { | ||||
|           out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|         } | ||||
|         out += ' } '; | ||||
|       } else { | ||||
|         out += ' {} '; | ||||
|       } | ||||
|       var __err = out; | ||||
|       out = $$outStack.pop(); | ||||
|       if (!it.compositeRule && $breakOnError) { | ||||
|         /* istanbul ignore if */ | ||||
|         if (it.async) { | ||||
|           out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|         } else { | ||||
|           out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|         } | ||||
|       } else { | ||||
|         out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|       } | ||||
|       out += ' } '; | ||||
|       $errSchemaPath = $currErrSchemaPath; | ||||
|       if ($breakOnError) { | ||||
|         $closingBraces += '}'; | ||||
|         out += ' else { '; | ||||
|       } | ||||
|     } | ||||
|     var arr1 = $schema; | ||||
|     if (arr1) { | ||||
|       var $sch, $i = -1, | ||||
|         l1 = arr1.length - 1; | ||||
|       while ($i < l1) { | ||||
|         $sch = arr1[$i += 1]; | ||||
|         if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { | ||||
|           out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($i) + ') { '; | ||||
|           var $passData = $data + '[' + $i + ']'; | ||||
|           $it.schema = $sch; | ||||
|           $it.schemaPath = $schemaPath + '[' + $i + ']'; | ||||
|           $it.errSchemaPath = $errSchemaPath + '/' + $i; | ||||
|           $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true); | ||||
|           $it.dataPathArr[$dataNxt] = $i; | ||||
|           var $code = it.validate($it); | ||||
|           $it.baseId = $currentBaseId; | ||||
|           if (it.util.varOccurences($code, $nextData) < 2) { | ||||
|             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; | ||||
|           } else { | ||||
|             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; | ||||
|           } | ||||
|           out += ' }  '; | ||||
|           if ($breakOnError) { | ||||
|             out += ' if (' + ($nextValid) + ') { '; | ||||
|             $closingBraces += '}'; | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? (typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0) || $additionalItems === false : it.util.schemaHasRules($additionalItems, it.RULES.all))) { | ||||
|       $it.schema = $additionalItems; | ||||
|       $it.schemaPath = it.schemaPath + '.additionalItems'; | ||||
|       $it.errSchemaPath = it.errSchemaPath + '/additionalItems'; | ||||
|       out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($schema.length) + ') {  for (var ' + ($idx) + ' = ' + ($schema.length) + '; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { '; | ||||
|       $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true); | ||||
|       var $passData = $data + '[' + $idx + ']'; | ||||
|       $it.dataPathArr[$dataNxt] = $idx; | ||||
|       var $code = it.validate($it); | ||||
|       $it.baseId = $currentBaseId; | ||||
|       if (it.util.varOccurences($code, $nextData) < 2) { | ||||
|         out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; | ||||
|       } else { | ||||
|         out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; | ||||
|       } | ||||
|       if ($breakOnError) { | ||||
|         out += ' if (!' + ($nextValid) + ') break; '; | ||||
|       } | ||||
|       out += ' } }  '; | ||||
|       if ($breakOnError) { | ||||
|         out += ' if (' + ($nextValid) + ') { '; | ||||
|         $closingBraces += '}'; | ||||
|       } | ||||
|     } | ||||
|   } else if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { | ||||
|     $it.schema = $schema; | ||||
|     $it.schemaPath = $schemaPath; | ||||
|     $it.errSchemaPath = $errSchemaPath; | ||||
|     out += '  for (var ' + ($idx) + ' = ' + (0) + '; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { '; | ||||
|     $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true); | ||||
|     var $passData = $data + '[' + $idx + ']'; | ||||
|     $it.dataPathArr[$dataNxt] = $idx; | ||||
|     var $code = it.validate($it); | ||||
|     $it.baseId = $currentBaseId; | ||||
|     if (it.util.varOccurences($code, $nextData) < 2) { | ||||
|       out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; | ||||
|     } else { | ||||
|       out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; | ||||
|     } | ||||
|     if ($breakOnError) { | ||||
|       out += ' if (!' + ($nextValid) + ') break; '; | ||||
|     } | ||||
|     out += ' }'; | ||||
|   } | ||||
|   if ($breakOnError) { | ||||
|     out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										80
									
								
								node_modules/ajv/lib/dotjs/multipleOf.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								node_modules/ajv/lib/dotjs/multipleOf.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,80 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_multipleOf(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   if (!($isData || typeof $schema == 'number')) { | ||||
|     throw new Error($keyword + ' must be number'); | ||||
|   } | ||||
|   out += 'var division' + ($lvl) + ';if ('; | ||||
|   if ($isData) { | ||||
|     out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || '; | ||||
|   } | ||||
|   out += ' (division' + ($lvl) + ' = ' + ($data) + ' / ' + ($schemaValue) + ', '; | ||||
|   if (it.opts.multipleOfPrecision) { | ||||
|     out += ' Math.abs(Math.round(division' + ($lvl) + ') - division' + ($lvl) + ') > 1e-' + (it.opts.multipleOfPrecision) + ' '; | ||||
|   } else { | ||||
|     out += ' division' + ($lvl) + ' !== parseInt(division' + ($lvl) + ') '; | ||||
|   } | ||||
|   out += ' ) '; | ||||
|   if ($isData) { | ||||
|     out += '  )  '; | ||||
|   } | ||||
|   out += ' ) {   '; | ||||
|   var $$outStack = $$outStack || []; | ||||
|   $$outStack.push(out); | ||||
|   out = ''; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ('multipleOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { multipleOf: ' + ($schemaValue) + ' } '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should be multiple of '; | ||||
|       if ($isData) { | ||||
|         out += '\' + ' + ($schemaValue); | ||||
|       } else { | ||||
|         out += '' + ($schemaValue) + '\''; | ||||
|       } | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema:  '; | ||||
|       if ($isData) { | ||||
|         out += 'validate.schema' + ($schemaPath); | ||||
|       } else { | ||||
|         out += '' + ($schema); | ||||
|       } | ||||
|       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   var __err = out; | ||||
|   out = $$outStack.pop(); | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   } | ||||
|   out += '} '; | ||||
|   if ($breakOnError) { | ||||
|     out += ' else { '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										84
									
								
								node_modules/ajv/lib/dotjs/not.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								node_modules/ajv/lib/dotjs/not.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,84 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_not(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $errs = 'errs__' + $lvl; | ||||
|   var $it = it.util.copy(it); | ||||
|   $it.level++; | ||||
|   var $nextValid = 'valid' + $it.level; | ||||
|   if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { | ||||
|     $it.schema = $schema; | ||||
|     $it.schemaPath = $schemaPath; | ||||
|     $it.errSchemaPath = $errSchemaPath; | ||||
|     out += ' var ' + ($errs) + ' = errors;  '; | ||||
|     var $wasComposite = it.compositeRule; | ||||
|     it.compositeRule = $it.compositeRule = true; | ||||
|     $it.createErrors = false; | ||||
|     var $allErrorsOption; | ||||
|     if ($it.opts.allErrors) { | ||||
|       $allErrorsOption = $it.opts.allErrors; | ||||
|       $it.opts.allErrors = false; | ||||
|     } | ||||
|     out += ' ' + (it.validate($it)) + ' '; | ||||
|     $it.createErrors = true; | ||||
|     if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption; | ||||
|     it.compositeRule = $it.compositeRule = $wasComposite; | ||||
|     out += ' if (' + ($nextValid) + ') {   '; | ||||
|     var $$outStack = $$outStack || []; | ||||
|     $$outStack.push(out); | ||||
|     out = ''; /* istanbul ignore else */ | ||||
|     if (it.createErrors !== false) { | ||||
|       out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; | ||||
|       if (it.opts.messages !== false) { | ||||
|         out += ' , message: \'should NOT be valid\' '; | ||||
|       } | ||||
|       if (it.opts.verbose) { | ||||
|         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|       } | ||||
|       out += ' } '; | ||||
|     } else { | ||||
|       out += ' {} '; | ||||
|     } | ||||
|     var __err = out; | ||||
|     out = $$outStack.pop(); | ||||
|     if (!it.compositeRule && $breakOnError) { | ||||
|       /* istanbul ignore if */ | ||||
|       if (it.async) { | ||||
|         out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|       } else { | ||||
|         out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|       } | ||||
|     } else { | ||||
|       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|     } | ||||
|     out += ' } else {  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } '; | ||||
|     if (it.opts.allErrors) { | ||||
|       out += ' } '; | ||||
|     } | ||||
|   } else { | ||||
|     out += '  var err =   '; /* istanbul ignore else */ | ||||
|     if (it.createErrors !== false) { | ||||
|       out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; | ||||
|       if (it.opts.messages !== false) { | ||||
|         out += ' , message: \'should NOT be valid\' '; | ||||
|       } | ||||
|       if (it.opts.verbose) { | ||||
|         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|       } | ||||
|       out += ' } '; | ||||
|     } else { | ||||
|       out += ' {} '; | ||||
|     } | ||||
|     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|     if ($breakOnError) { | ||||
|       out += ' if (false) { '; | ||||
|     } | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										73
									
								
								node_modules/ajv/lib/dotjs/oneOf.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								node_modules/ajv/lib/dotjs/oneOf.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_oneOf(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $errs = 'errs__' + $lvl; | ||||
|   var $it = it.util.copy(it); | ||||
|   var $closingBraces = ''; | ||||
|   $it.level++; | ||||
|   var $nextValid = 'valid' + $it.level; | ||||
|   var $currentBaseId = $it.baseId, | ||||
|     $prevValid = 'prevValid' + $lvl, | ||||
|     $passingSchemas = 'passingSchemas' + $lvl; | ||||
|   out += 'var ' + ($errs) + ' = errors , ' + ($prevValid) + ' = false , ' + ($valid) + ' = false , ' + ($passingSchemas) + ' = null; '; | ||||
|   var $wasComposite = it.compositeRule; | ||||
|   it.compositeRule = $it.compositeRule = true; | ||||
|   var arr1 = $schema; | ||||
|   if (arr1) { | ||||
|     var $sch, $i = -1, | ||||
|       l1 = arr1.length - 1; | ||||
|     while ($i < l1) { | ||||
|       $sch = arr1[$i += 1]; | ||||
|       if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { | ||||
|         $it.schema = $sch; | ||||
|         $it.schemaPath = $schemaPath + '[' + $i + ']'; | ||||
|         $it.errSchemaPath = $errSchemaPath + '/' + $i; | ||||
|         out += '  ' + (it.validate($it)) + ' '; | ||||
|         $it.baseId = $currentBaseId; | ||||
|       } else { | ||||
|         out += ' var ' + ($nextValid) + ' = true; '; | ||||
|       } | ||||
|       if ($i) { | ||||
|         out += ' if (' + ($nextValid) + ' && ' + ($prevValid) + ') { ' + ($valid) + ' = false; ' + ($passingSchemas) + ' = [' + ($passingSchemas) + ', ' + ($i) + ']; } else { '; | ||||
|         $closingBraces += '}'; | ||||
|       } | ||||
|       out += ' if (' + ($nextValid) + ') { ' + ($valid) + ' = ' + ($prevValid) + ' = true; ' + ($passingSchemas) + ' = ' + ($i) + '; }'; | ||||
|     } | ||||
|   } | ||||
|   it.compositeRule = $it.compositeRule = $wasComposite; | ||||
|   out += '' + ($closingBraces) + 'if (!' + ($valid) + ') {   var err =   '; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ('oneOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { passingSchemas: ' + ($passingSchemas) + ' } '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should match exactly one schema in oneOf\' '; | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError(vErrors); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = vErrors; return false; '; | ||||
|     } | ||||
|   } | ||||
|   out += '} else {  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; }'; | ||||
|   if (it.opts.allErrors) { | ||||
|     out += ' } '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										75
									
								
								node_modules/ajv/lib/dotjs/pattern.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								node_modules/ajv/lib/dotjs/pattern.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_pattern(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema); | ||||
|   out += 'if ( '; | ||||
|   if ($isData) { | ||||
|     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || '; | ||||
|   } | ||||
|   out += ' !' + ($regexp) + '.test(' + ($data) + ') ) {   '; | ||||
|   var $$outStack = $$outStack || []; | ||||
|   $$outStack.push(out); | ||||
|   out = ''; /* istanbul ignore else */ | ||||
|   if (it.createErrors !== false) { | ||||
|     out += ' { keyword: \'' + ('pattern') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { pattern:  '; | ||||
|     if ($isData) { | ||||
|       out += '' + ($schemaValue); | ||||
|     } else { | ||||
|       out += '' + (it.util.toQuotedString($schema)); | ||||
|     } | ||||
|     out += '  } '; | ||||
|     if (it.opts.messages !== false) { | ||||
|       out += ' , message: \'should match pattern "'; | ||||
|       if ($isData) { | ||||
|         out += '\' + ' + ($schemaValue) + ' + \''; | ||||
|       } else { | ||||
|         out += '' + (it.util.escapeQuotes($schema)); | ||||
|       } | ||||
|       out += '"\' '; | ||||
|     } | ||||
|     if (it.opts.verbose) { | ||||
|       out += ' , schema:  '; | ||||
|       if ($isData) { | ||||
|         out += 'validate.schema' + ($schemaPath); | ||||
|       } else { | ||||
|         out += '' + (it.util.toQuotedString($schema)); | ||||
|       } | ||||
|       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|   } else { | ||||
|     out += ' {} '; | ||||
|   } | ||||
|   var __err = out; | ||||
|   out = $$outStack.pop(); | ||||
|   if (!it.compositeRule && $breakOnError) { | ||||
|     /* istanbul ignore if */ | ||||
|     if (it.async) { | ||||
|       out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|     } | ||||
|   } else { | ||||
|     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|   } | ||||
|   out += '} '; | ||||
|   if ($breakOnError) { | ||||
|     out += ' else { '; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										335
									
								
								node_modules/ajv/lib/dotjs/properties.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										335
									
								
								node_modules/ajv/lib/dotjs/properties.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,335 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_properties(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $errs = 'errs__' + $lvl; | ||||
|   var $it = it.util.copy(it); | ||||
|   var $closingBraces = ''; | ||||
|   $it.level++; | ||||
|   var $nextValid = 'valid' + $it.level; | ||||
|   var $key = 'key' + $lvl, | ||||
|     $idx = 'idx' + $lvl, | ||||
|     $dataNxt = $it.dataLevel = it.dataLevel + 1, | ||||
|     $nextData = 'data' + $dataNxt, | ||||
|     $dataProperties = 'dataProperties' + $lvl; | ||||
|   var $schemaKeys = Object.keys($schema || {}).filter(notProto), | ||||
|     $pProperties = it.schema.patternProperties || {}, | ||||
|     $pPropertyKeys = Object.keys($pProperties).filter(notProto), | ||||
|     $aProperties = it.schema.additionalProperties, | ||||
|     $someProperties = $schemaKeys.length || $pPropertyKeys.length, | ||||
|     $noAdditional = $aProperties === false, | ||||
|     $additionalIsSchema = typeof $aProperties == 'object' && Object.keys($aProperties).length, | ||||
|     $removeAdditional = it.opts.removeAdditional, | ||||
|     $checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional, | ||||
|     $ownProperties = it.opts.ownProperties, | ||||
|     $currentBaseId = it.baseId; | ||||
|   var $required = it.schema.required; | ||||
|   if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) { | ||||
|     var $requiredHash = it.util.toHash($required); | ||||
|   } | ||||
|  | ||||
|   function notProto(p) { | ||||
|     return p !== '__proto__'; | ||||
|   } | ||||
|   out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;'; | ||||
|   if ($ownProperties) { | ||||
|     out += ' var ' + ($dataProperties) + ' = undefined;'; | ||||
|   } | ||||
|   if ($checkAdditional) { | ||||
|     if ($ownProperties) { | ||||
|       out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; '; | ||||
|     } else { | ||||
|       out += ' for (var ' + ($key) + ' in ' + ($data) + ') { '; | ||||
|     } | ||||
|     if ($someProperties) { | ||||
|       out += ' var isAdditional' + ($lvl) + ' = !(false '; | ||||
|       if ($schemaKeys.length) { | ||||
|         if ($schemaKeys.length > 8) { | ||||
|           out += ' || validate.schema' + ($schemaPath) + '.hasOwnProperty(' + ($key) + ') '; | ||||
|         } else { | ||||
|           var arr1 = $schemaKeys; | ||||
|           if (arr1) { | ||||
|             var $propertyKey, i1 = -1, | ||||
|               l1 = arr1.length - 1; | ||||
|             while (i1 < l1) { | ||||
|               $propertyKey = arr1[i1 += 1]; | ||||
|               out += ' || ' + ($key) + ' == ' + (it.util.toQuotedString($propertyKey)) + ' '; | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       if ($pPropertyKeys.length) { | ||||
|         var arr2 = $pPropertyKeys; | ||||
|         if (arr2) { | ||||
|           var $pProperty, $i = -1, | ||||
|             l2 = arr2.length - 1; | ||||
|           while ($i < l2) { | ||||
|             $pProperty = arr2[$i += 1]; | ||||
|             out += ' || ' + (it.usePattern($pProperty)) + '.test(' + ($key) + ') '; | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       out += ' ); if (isAdditional' + ($lvl) + ') { '; | ||||
|     } | ||||
|     if ($removeAdditional == 'all') { | ||||
|       out += ' delete ' + ($data) + '[' + ($key) + ']; '; | ||||
|     } else { | ||||
|       var $currentErrorPath = it.errorPath; | ||||
|       var $additionalProperty = '\' + ' + $key + ' + \''; | ||||
|       if (it.opts._errorDataPathProperty) { | ||||
|         it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers); | ||||
|       } | ||||
|       if ($noAdditional) { | ||||
|         if ($removeAdditional) { | ||||
|           out += ' delete ' + ($data) + '[' + ($key) + ']; '; | ||||
|         } else { | ||||
|           out += ' ' + ($nextValid) + ' = false; '; | ||||
|           var $currErrSchemaPath = $errSchemaPath; | ||||
|           $errSchemaPath = it.errSchemaPath + '/additionalProperties'; | ||||
|           var $$outStack = $$outStack || []; | ||||
|           $$outStack.push(out); | ||||
|           out = ''; /* istanbul ignore else */ | ||||
|           if (it.createErrors !== false) { | ||||
|             out += ' { keyword: \'' + ('additionalProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { additionalProperty: \'' + ($additionalProperty) + '\' } '; | ||||
|             if (it.opts.messages !== false) { | ||||
|               out += ' , message: \''; | ||||
|               if (it.opts._errorDataPathProperty) { | ||||
|                 out += 'is an invalid additional property'; | ||||
|               } else { | ||||
|                 out += 'should NOT have additional properties'; | ||||
|               } | ||||
|               out += '\' '; | ||||
|             } | ||||
|             if (it.opts.verbose) { | ||||
|               out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|             } | ||||
|             out += ' } '; | ||||
|           } else { | ||||
|             out += ' {} '; | ||||
|           } | ||||
|           var __err = out; | ||||
|           out = $$outStack.pop(); | ||||
|           if (!it.compositeRule && $breakOnError) { | ||||
|             /* istanbul ignore if */ | ||||
|             if (it.async) { | ||||
|               out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|             } else { | ||||
|               out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|             } | ||||
|           } else { | ||||
|             out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|           } | ||||
|           $errSchemaPath = $currErrSchemaPath; | ||||
|           if ($breakOnError) { | ||||
|             out += ' break; '; | ||||
|           } | ||||
|         } | ||||
|       } else if ($additionalIsSchema) { | ||||
|         if ($removeAdditional == 'failing') { | ||||
|           out += ' var ' + ($errs) + ' = errors;  '; | ||||
|           var $wasComposite = it.compositeRule; | ||||
|           it.compositeRule = $it.compositeRule = true; | ||||
|           $it.schema = $aProperties; | ||||
|           $it.schemaPath = it.schemaPath + '.additionalProperties'; | ||||
|           $it.errSchemaPath = it.errSchemaPath + '/additionalProperties'; | ||||
|           $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers); | ||||
|           var $passData = $data + '[' + $key + ']'; | ||||
|           $it.dataPathArr[$dataNxt] = $key; | ||||
|           var $code = it.validate($it); | ||||
|           $it.baseId = $currentBaseId; | ||||
|           if (it.util.varOccurences($code, $nextData) < 2) { | ||||
|             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; | ||||
|           } else { | ||||
|             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; | ||||
|           } | ||||
|           out += ' if (!' + ($nextValid) + ') { errors = ' + ($errs) + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + ($data) + '[' + ($key) + ']; }  '; | ||||
|           it.compositeRule = $it.compositeRule = $wasComposite; | ||||
|         } else { | ||||
|           $it.schema = $aProperties; | ||||
|           $it.schemaPath = it.schemaPath + '.additionalProperties'; | ||||
|           $it.errSchemaPath = it.errSchemaPath + '/additionalProperties'; | ||||
|           $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers); | ||||
|           var $passData = $data + '[' + $key + ']'; | ||||
|           $it.dataPathArr[$dataNxt] = $key; | ||||
|           var $code = it.validate($it); | ||||
|           $it.baseId = $currentBaseId; | ||||
|           if (it.util.varOccurences($code, $nextData) < 2) { | ||||
|             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; | ||||
|           } else { | ||||
|             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; | ||||
|           } | ||||
|           if ($breakOnError) { | ||||
|             out += ' if (!' + ($nextValid) + ') break; '; | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       it.errorPath = $currentErrorPath; | ||||
|     } | ||||
|     if ($someProperties) { | ||||
|       out += ' } '; | ||||
|     } | ||||
|     out += ' }  '; | ||||
|     if ($breakOnError) { | ||||
|       out += ' if (' + ($nextValid) + ') { '; | ||||
|       $closingBraces += '}'; | ||||
|     } | ||||
|   } | ||||
|   var $useDefaults = it.opts.useDefaults && !it.compositeRule; | ||||
|   if ($schemaKeys.length) { | ||||
|     var arr3 = $schemaKeys; | ||||
|     if (arr3) { | ||||
|       var $propertyKey, i3 = -1, | ||||
|         l3 = arr3.length - 1; | ||||
|       while (i3 < l3) { | ||||
|         $propertyKey = arr3[i3 += 1]; | ||||
|         var $sch = $schema[$propertyKey]; | ||||
|         if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { | ||||
|           var $prop = it.util.getProperty($propertyKey), | ||||
|             $passData = $data + $prop, | ||||
|             $hasDefault = $useDefaults && $sch.default !== undefined; | ||||
|           $it.schema = $sch; | ||||
|           $it.schemaPath = $schemaPath + $prop; | ||||
|           $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey); | ||||
|           $it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers); | ||||
|           $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey); | ||||
|           var $code = it.validate($it); | ||||
|           $it.baseId = $currentBaseId; | ||||
|           if (it.util.varOccurences($code, $nextData) < 2) { | ||||
|             $code = it.util.varReplace($code, $nextData, $passData); | ||||
|             var $useData = $passData; | ||||
|           } else { | ||||
|             var $useData = $nextData; | ||||
|             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; '; | ||||
|           } | ||||
|           if ($hasDefault) { | ||||
|             out += ' ' + ($code) + ' '; | ||||
|           } else { | ||||
|             if ($requiredHash && $requiredHash[$propertyKey]) { | ||||
|               out += ' if ( ' + ($useData) + ' === undefined '; | ||||
|               if ($ownProperties) { | ||||
|                 out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; | ||||
|               } | ||||
|               out += ') { ' + ($nextValid) + ' = false; '; | ||||
|               var $currentErrorPath = it.errorPath, | ||||
|                 $currErrSchemaPath = $errSchemaPath, | ||||
|                 $missingProperty = it.util.escapeQuotes($propertyKey); | ||||
|               if (it.opts._errorDataPathProperty) { | ||||
|                 it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers); | ||||
|               } | ||||
|               $errSchemaPath = it.errSchemaPath + '/required'; | ||||
|               var $$outStack = $$outStack || []; | ||||
|               $$outStack.push(out); | ||||
|               out = ''; /* istanbul ignore else */ | ||||
|               if (it.createErrors !== false) { | ||||
|                 out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; | ||||
|                 if (it.opts.messages !== false) { | ||||
|                   out += ' , message: \''; | ||||
|                   if (it.opts._errorDataPathProperty) { | ||||
|                     out += 'is a required property'; | ||||
|                   } else { | ||||
|                     out += 'should have required property \\\'' + ($missingProperty) + '\\\''; | ||||
|                   } | ||||
|                   out += '\' '; | ||||
|                 } | ||||
|                 if (it.opts.verbose) { | ||||
|                   out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|                 } | ||||
|                 out += ' } '; | ||||
|               } else { | ||||
|                 out += ' {} '; | ||||
|               } | ||||
|               var __err = out; | ||||
|               out = $$outStack.pop(); | ||||
|               if (!it.compositeRule && $breakOnError) { | ||||
|                 /* istanbul ignore if */ | ||||
|                 if (it.async) { | ||||
|                   out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|                 } else { | ||||
|                   out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|                 } | ||||
|               } else { | ||||
|                 out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|               } | ||||
|               $errSchemaPath = $currErrSchemaPath; | ||||
|               it.errorPath = $currentErrorPath; | ||||
|               out += ' } else { '; | ||||
|             } else { | ||||
|               if ($breakOnError) { | ||||
|                 out += ' if ( ' + ($useData) + ' === undefined '; | ||||
|                 if ($ownProperties) { | ||||
|                   out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; | ||||
|                 } | ||||
|                 out += ') { ' + ($nextValid) + ' = true; } else { '; | ||||
|               } else { | ||||
|                 out += ' if (' + ($useData) + ' !== undefined '; | ||||
|                 if ($ownProperties) { | ||||
|                   out += ' &&   Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; | ||||
|                 } | ||||
|                 out += ' ) { '; | ||||
|               } | ||||
|             } | ||||
|             out += ' ' + ($code) + ' } '; | ||||
|           } | ||||
|         } | ||||
|         if ($breakOnError) { | ||||
|           out += ' if (' + ($nextValid) + ') { '; | ||||
|           $closingBraces += '}'; | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   if ($pPropertyKeys.length) { | ||||
|     var arr4 = $pPropertyKeys; | ||||
|     if (arr4) { | ||||
|       var $pProperty, i4 = -1, | ||||
|         l4 = arr4.length - 1; | ||||
|       while (i4 < l4) { | ||||
|         $pProperty = arr4[i4 += 1]; | ||||
|         var $sch = $pProperties[$pProperty]; | ||||
|         if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { | ||||
|           $it.schema = $sch; | ||||
|           $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty); | ||||
|           $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty); | ||||
|           if ($ownProperties) { | ||||
|             out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; '; | ||||
|           } else { | ||||
|             out += ' for (var ' + ($key) + ' in ' + ($data) + ') { '; | ||||
|           } | ||||
|           out += ' if (' + (it.usePattern($pProperty)) + '.test(' + ($key) + ')) { '; | ||||
|           $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers); | ||||
|           var $passData = $data + '[' + $key + ']'; | ||||
|           $it.dataPathArr[$dataNxt] = $key; | ||||
|           var $code = it.validate($it); | ||||
|           $it.baseId = $currentBaseId; | ||||
|           if (it.util.varOccurences($code, $nextData) < 2) { | ||||
|             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; | ||||
|           } else { | ||||
|             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; | ||||
|           } | ||||
|           if ($breakOnError) { | ||||
|             out += ' if (!' + ($nextValid) + ') break; '; | ||||
|           } | ||||
|           out += ' } '; | ||||
|           if ($breakOnError) { | ||||
|             out += ' else ' + ($nextValid) + ' = true; '; | ||||
|           } | ||||
|           out += ' }  '; | ||||
|           if ($breakOnError) { | ||||
|             out += ' if (' + ($nextValid) + ') { '; | ||||
|             $closingBraces += '}'; | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   if ($breakOnError) { | ||||
|     out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										81
									
								
								node_modules/ajv/lib/dotjs/propertyNames.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								node_modules/ajv/lib/dotjs/propertyNames.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,81 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_propertyNames(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $errs = 'errs__' + $lvl; | ||||
|   var $it = it.util.copy(it); | ||||
|   var $closingBraces = ''; | ||||
|   $it.level++; | ||||
|   var $nextValid = 'valid' + $it.level; | ||||
|   out += 'var ' + ($errs) + ' = errors;'; | ||||
|   if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { | ||||
|     $it.schema = $schema; | ||||
|     $it.schemaPath = $schemaPath; | ||||
|     $it.errSchemaPath = $errSchemaPath; | ||||
|     var $key = 'key' + $lvl, | ||||
|       $idx = 'idx' + $lvl, | ||||
|       $i = 'i' + $lvl, | ||||
|       $invalidName = '\' + ' + $key + ' + \'', | ||||
|       $dataNxt = $it.dataLevel = it.dataLevel + 1, | ||||
|       $nextData = 'data' + $dataNxt, | ||||
|       $dataProperties = 'dataProperties' + $lvl, | ||||
|       $ownProperties = it.opts.ownProperties, | ||||
|       $currentBaseId = it.baseId; | ||||
|     if ($ownProperties) { | ||||
|       out += ' var ' + ($dataProperties) + ' = undefined; '; | ||||
|     } | ||||
|     if ($ownProperties) { | ||||
|       out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; '; | ||||
|     } else { | ||||
|       out += ' for (var ' + ($key) + ' in ' + ($data) + ') { '; | ||||
|     } | ||||
|     out += ' var startErrs' + ($lvl) + ' = errors; '; | ||||
|     var $passData = $key; | ||||
|     var $wasComposite = it.compositeRule; | ||||
|     it.compositeRule = $it.compositeRule = true; | ||||
|     var $code = it.validate($it); | ||||
|     $it.baseId = $currentBaseId; | ||||
|     if (it.util.varOccurences($code, $nextData) < 2) { | ||||
|       out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; | ||||
|     } else { | ||||
|       out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; | ||||
|     } | ||||
|     it.compositeRule = $it.compositeRule = $wasComposite; | ||||
|     out += ' if (!' + ($nextValid) + ') { for (var ' + ($i) + '=startErrs' + ($lvl) + '; ' + ($i) + '<errors; ' + ($i) + '++) { vErrors[' + ($i) + '].propertyName = ' + ($key) + '; }   var err =   '; /* istanbul ignore else */ | ||||
|     if (it.createErrors !== false) { | ||||
|       out += ' { keyword: \'' + ('propertyNames') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { propertyName: \'' + ($invalidName) + '\' } '; | ||||
|       if (it.opts.messages !== false) { | ||||
|         out += ' , message: \'property name \\\'' + ($invalidName) + '\\\' is invalid\' '; | ||||
|       } | ||||
|       if (it.opts.verbose) { | ||||
|         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|       } | ||||
|       out += ' } '; | ||||
|     } else { | ||||
|       out += ' {} '; | ||||
|     } | ||||
|     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|     if (!it.compositeRule && $breakOnError) { | ||||
|       /* istanbul ignore if */ | ||||
|       if (it.async) { | ||||
|         out += ' throw new ValidationError(vErrors); '; | ||||
|       } else { | ||||
|         out += ' validate.errors = vErrors; return false; '; | ||||
|       } | ||||
|     } | ||||
|     if ($breakOnError) { | ||||
|       out += ' break; '; | ||||
|     } | ||||
|     out += ' } }'; | ||||
|   } | ||||
|   if ($breakOnError) { | ||||
|     out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										124
									
								
								node_modules/ajv/lib/dotjs/ref.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								node_modules/ajv/lib/dotjs/ref.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,124 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_ref(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $async, $refCode; | ||||
|   if ($schema == '#' || $schema == '#/') { | ||||
|     if (it.isRoot) { | ||||
|       $async = it.async; | ||||
|       $refCode = 'validate'; | ||||
|     } else { | ||||
|       $async = it.root.schema.$async === true; | ||||
|       $refCode = 'root.refVal[0]'; | ||||
|     } | ||||
|   } else { | ||||
|     var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot); | ||||
|     if ($refVal === undefined) { | ||||
|       var $message = it.MissingRefError.message(it.baseId, $schema); | ||||
|       if (it.opts.missingRefs == 'fail') { | ||||
|         it.logger.error($message); | ||||
|         var $$outStack = $$outStack || []; | ||||
|         $$outStack.push(out); | ||||
|         out = ''; /* istanbul ignore else */ | ||||
|         if (it.createErrors !== false) { | ||||
|           out += ' { keyword: \'' + ('$ref') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { ref: \'' + (it.util.escapeQuotes($schema)) + '\' } '; | ||||
|           if (it.opts.messages !== false) { | ||||
|             out += ' , message: \'can\\\'t resolve reference ' + (it.util.escapeQuotes($schema)) + '\' '; | ||||
|           } | ||||
|           if (it.opts.verbose) { | ||||
|             out += ' , schema: ' + (it.util.toQuotedString($schema)) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|           } | ||||
|           out += ' } '; | ||||
|         } else { | ||||
|           out += ' {} '; | ||||
|         } | ||||
|         var __err = out; | ||||
|         out = $$outStack.pop(); | ||||
|         if (!it.compositeRule && $breakOnError) { | ||||
|           /* istanbul ignore if */ | ||||
|           if (it.async) { | ||||
|             out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|           } else { | ||||
|             out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|           } | ||||
|         } else { | ||||
|           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|         } | ||||
|         if ($breakOnError) { | ||||
|           out += ' if (false) { '; | ||||
|         } | ||||
|       } else if (it.opts.missingRefs == 'ignore') { | ||||
|         it.logger.warn($message); | ||||
|         if ($breakOnError) { | ||||
|           out += ' if (true) { '; | ||||
|         } | ||||
|       } else { | ||||
|         throw new it.MissingRefError(it.baseId, $schema, $message); | ||||
|       } | ||||
|     } else if ($refVal.inline) { | ||||
|       var $it = it.util.copy(it); | ||||
|       $it.level++; | ||||
|       var $nextValid = 'valid' + $it.level; | ||||
|       $it.schema = $refVal.schema; | ||||
|       $it.schemaPath = ''; | ||||
|       $it.errSchemaPath = $schema; | ||||
|       var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code); | ||||
|       out += ' ' + ($code) + ' '; | ||||
|       if ($breakOnError) { | ||||
|         out += ' if (' + ($nextValid) + ') { '; | ||||
|       } | ||||
|     } else { | ||||
|       $async = $refVal.$async === true || (it.async && $refVal.$async !== false); | ||||
|       $refCode = $refVal.code; | ||||
|     } | ||||
|   } | ||||
|   if ($refCode) { | ||||
|     var $$outStack = $$outStack || []; | ||||
|     $$outStack.push(out); | ||||
|     out = ''; | ||||
|     if (it.opts.passContext) { | ||||
|       out += ' ' + ($refCode) + '.call(this, '; | ||||
|     } else { | ||||
|       out += ' ' + ($refCode) + '( '; | ||||
|     } | ||||
|     out += ' ' + ($data) + ', (dataPath || \'\')'; | ||||
|     if (it.errorPath != '""') { | ||||
|       out += ' + ' + (it.errorPath); | ||||
|     } | ||||
|     var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData', | ||||
|       $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty'; | ||||
|     out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ', rootData)  '; | ||||
|     var __callValidate = out; | ||||
|     out = $$outStack.pop(); | ||||
|     if ($async) { | ||||
|       if (!it.async) throw new Error('async schema referenced by sync schema'); | ||||
|       if ($breakOnError) { | ||||
|         out += ' var ' + ($valid) + '; '; | ||||
|       } | ||||
|       out += ' try { await ' + (__callValidate) + '; '; | ||||
|       if ($breakOnError) { | ||||
|         out += ' ' + ($valid) + ' = true; '; | ||||
|       } | ||||
|       out += ' } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; '; | ||||
|       if ($breakOnError) { | ||||
|         out += ' ' + ($valid) + ' = false; '; | ||||
|       } | ||||
|       out += ' } '; | ||||
|       if ($breakOnError) { | ||||
|         out += ' if (' + ($valid) + ') { '; | ||||
|       } | ||||
|     } else { | ||||
|       out += ' if (!' + (__callValidate) + ') { if (vErrors === null) vErrors = ' + ($refCode) + '.errors; else vErrors = vErrors.concat(' + ($refCode) + '.errors); errors = vErrors.length; } '; | ||||
|       if ($breakOnError) { | ||||
|         out += ' else { '; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										270
									
								
								node_modules/ajv/lib/dotjs/required.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										270
									
								
								node_modules/ajv/lib/dotjs/required.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,270 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_required(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   var $vSchema = 'schema' + $lvl; | ||||
|   if (!$isData) { | ||||
|     if ($schema.length < it.opts.loopRequired && it.schema.properties && Object.keys(it.schema.properties).length) { | ||||
|       var $required = []; | ||||
|       var arr1 = $schema; | ||||
|       if (arr1) { | ||||
|         var $property, i1 = -1, | ||||
|           l1 = arr1.length - 1; | ||||
|         while (i1 < l1) { | ||||
|           $property = arr1[i1 += 1]; | ||||
|           var $propertySch = it.schema.properties[$property]; | ||||
|           if (!($propertySch && (it.opts.strictKeywords ? (typeof $propertySch == 'object' && Object.keys($propertySch).length > 0) || $propertySch === false : it.util.schemaHasRules($propertySch, it.RULES.all)))) { | ||||
|             $required[$required.length] = $property; | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } else { | ||||
|       var $required = $schema; | ||||
|     } | ||||
|   } | ||||
|   if ($isData || $required.length) { | ||||
|     var $currentErrorPath = it.errorPath, | ||||
|       $loopRequired = $isData || $required.length >= it.opts.loopRequired, | ||||
|       $ownProperties = it.opts.ownProperties; | ||||
|     if ($breakOnError) { | ||||
|       out += ' var missing' + ($lvl) + '; '; | ||||
|       if ($loopRequired) { | ||||
|         if (!$isData) { | ||||
|           out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + '; '; | ||||
|         } | ||||
|         var $i = 'i' + $lvl, | ||||
|           $propertyPath = 'schema' + $lvl + '[' + $i + ']', | ||||
|           $missingProperty = '\' + ' + $propertyPath + ' + \''; | ||||
|         if (it.opts._errorDataPathProperty) { | ||||
|           it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers); | ||||
|         } | ||||
|         out += ' var ' + ($valid) + ' = true; '; | ||||
|         if ($isData) { | ||||
|           out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {'; | ||||
|         } | ||||
|         out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { ' + ($valid) + ' = ' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] !== undefined '; | ||||
|         if ($ownProperties) { | ||||
|           out += ' &&   Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) '; | ||||
|         } | ||||
|         out += '; if (!' + ($valid) + ') break; } '; | ||||
|         if ($isData) { | ||||
|           out += '  }  '; | ||||
|         } | ||||
|         out += '  if (!' + ($valid) + ') {   '; | ||||
|         var $$outStack = $$outStack || []; | ||||
|         $$outStack.push(out); | ||||
|         out = ''; /* istanbul ignore else */ | ||||
|         if (it.createErrors !== false) { | ||||
|           out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; | ||||
|           if (it.opts.messages !== false) { | ||||
|             out += ' , message: \''; | ||||
|             if (it.opts._errorDataPathProperty) { | ||||
|               out += 'is a required property'; | ||||
|             } else { | ||||
|               out += 'should have required property \\\'' + ($missingProperty) + '\\\''; | ||||
|             } | ||||
|             out += '\' '; | ||||
|           } | ||||
|           if (it.opts.verbose) { | ||||
|             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|           } | ||||
|           out += ' } '; | ||||
|         } else { | ||||
|           out += ' {} '; | ||||
|         } | ||||
|         var __err = out; | ||||
|         out = $$outStack.pop(); | ||||
|         if (!it.compositeRule && $breakOnError) { | ||||
|           /* istanbul ignore if */ | ||||
|           if (it.async) { | ||||
|             out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|           } else { | ||||
|             out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|           } | ||||
|         } else { | ||||
|           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|         } | ||||
|         out += ' } else { '; | ||||
|       } else { | ||||
|         out += ' if ( '; | ||||
|         var arr2 = $required; | ||||
|         if (arr2) { | ||||
|           var $propertyKey, $i = -1, | ||||
|             l2 = arr2.length - 1; | ||||
|           while ($i < l2) { | ||||
|             $propertyKey = arr2[$i += 1]; | ||||
|             if ($i) { | ||||
|               out += ' || '; | ||||
|             } | ||||
|             var $prop = it.util.getProperty($propertyKey), | ||||
|               $useData = $data + $prop; | ||||
|             out += ' ( ( ' + ($useData) + ' === undefined '; | ||||
|             if ($ownProperties) { | ||||
|               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; | ||||
|             } | ||||
|             out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) '; | ||||
|           } | ||||
|         } | ||||
|         out += ') {  '; | ||||
|         var $propertyPath = 'missing' + $lvl, | ||||
|           $missingProperty = '\' + ' + $propertyPath + ' + \''; | ||||
|         if (it.opts._errorDataPathProperty) { | ||||
|           it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath; | ||||
|         } | ||||
|         var $$outStack = $$outStack || []; | ||||
|         $$outStack.push(out); | ||||
|         out = ''; /* istanbul ignore else */ | ||||
|         if (it.createErrors !== false) { | ||||
|           out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; | ||||
|           if (it.opts.messages !== false) { | ||||
|             out += ' , message: \''; | ||||
|             if (it.opts._errorDataPathProperty) { | ||||
|               out += 'is a required property'; | ||||
|             } else { | ||||
|               out += 'should have required property \\\'' + ($missingProperty) + '\\\''; | ||||
|             } | ||||
|             out += '\' '; | ||||
|           } | ||||
|           if (it.opts.verbose) { | ||||
|             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|           } | ||||
|           out += ' } '; | ||||
|         } else { | ||||
|           out += ' {} '; | ||||
|         } | ||||
|         var __err = out; | ||||
|         out = $$outStack.pop(); | ||||
|         if (!it.compositeRule && $breakOnError) { | ||||
|           /* istanbul ignore if */ | ||||
|           if (it.async) { | ||||
|             out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|           } else { | ||||
|             out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|           } | ||||
|         } else { | ||||
|           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|         } | ||||
|         out += ' } else { '; | ||||
|       } | ||||
|     } else { | ||||
|       if ($loopRequired) { | ||||
|         if (!$isData) { | ||||
|           out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + '; '; | ||||
|         } | ||||
|         var $i = 'i' + $lvl, | ||||
|           $propertyPath = 'schema' + $lvl + '[' + $i + ']', | ||||
|           $missingProperty = '\' + ' + $propertyPath + ' + \''; | ||||
|         if (it.opts._errorDataPathProperty) { | ||||
|           it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers); | ||||
|         } | ||||
|         if ($isData) { | ||||
|           out += ' if (' + ($vSchema) + ' && !Array.isArray(' + ($vSchema) + ')) {  var err =   '; /* istanbul ignore else */ | ||||
|           if (it.createErrors !== false) { | ||||
|             out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; | ||||
|             if (it.opts.messages !== false) { | ||||
|               out += ' , message: \''; | ||||
|               if (it.opts._errorDataPathProperty) { | ||||
|                 out += 'is a required property'; | ||||
|               } else { | ||||
|                 out += 'should have required property \\\'' + ($missingProperty) + '\\\''; | ||||
|               } | ||||
|               out += '\' '; | ||||
|             } | ||||
|             if (it.opts.verbose) { | ||||
|               out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|             } | ||||
|             out += ' } '; | ||||
|           } else { | ||||
|             out += ' {} '; | ||||
|           } | ||||
|           out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (' + ($vSchema) + ' !== undefined) { '; | ||||
|         } | ||||
|         out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { if (' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] === undefined '; | ||||
|         if ($ownProperties) { | ||||
|           out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) '; | ||||
|         } | ||||
|         out += ') {  var err =   '; /* istanbul ignore else */ | ||||
|         if (it.createErrors !== false) { | ||||
|           out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; | ||||
|           if (it.opts.messages !== false) { | ||||
|             out += ' , message: \''; | ||||
|             if (it.opts._errorDataPathProperty) { | ||||
|               out += 'is a required property'; | ||||
|             } else { | ||||
|               out += 'should have required property \\\'' + ($missingProperty) + '\\\''; | ||||
|             } | ||||
|             out += '\' '; | ||||
|           } | ||||
|           if (it.opts.verbose) { | ||||
|             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|           } | ||||
|           out += ' } '; | ||||
|         } else { | ||||
|           out += ' {} '; | ||||
|         } | ||||
|         out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } '; | ||||
|         if ($isData) { | ||||
|           out += '  }  '; | ||||
|         } | ||||
|       } else { | ||||
|         var arr3 = $required; | ||||
|         if (arr3) { | ||||
|           var $propertyKey, i3 = -1, | ||||
|             l3 = arr3.length - 1; | ||||
|           while (i3 < l3) { | ||||
|             $propertyKey = arr3[i3 += 1]; | ||||
|             var $prop = it.util.getProperty($propertyKey), | ||||
|               $missingProperty = it.util.escapeQuotes($propertyKey), | ||||
|               $useData = $data + $prop; | ||||
|             if (it.opts._errorDataPathProperty) { | ||||
|               it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers); | ||||
|             } | ||||
|             out += ' if ( ' + ($useData) + ' === undefined '; | ||||
|             if ($ownProperties) { | ||||
|               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; | ||||
|             } | ||||
|             out += ') {  var err =   '; /* istanbul ignore else */ | ||||
|             if (it.createErrors !== false) { | ||||
|               out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; | ||||
|               if (it.opts.messages !== false) { | ||||
|                 out += ' , message: \''; | ||||
|                 if (it.opts._errorDataPathProperty) { | ||||
|                   out += 'is a required property'; | ||||
|                 } else { | ||||
|                   out += 'should have required property \\\'' + ($missingProperty) + '\\\''; | ||||
|                 } | ||||
|                 out += '\' '; | ||||
|               } | ||||
|               if (it.opts.verbose) { | ||||
|                 out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|               } | ||||
|               out += ' } '; | ||||
|             } else { | ||||
|               out += ' {} '; | ||||
|             } | ||||
|             out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } '; | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     it.errorPath = $currentErrorPath; | ||||
|   } else if ($breakOnError) { | ||||
|     out += ' if (true) {'; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										86
									
								
								node_modules/ajv/lib/dotjs/uniqueItems.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								node_modules/ajv/lib/dotjs/uniqueItems.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,86 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_uniqueItems(it, $keyword, $ruleType) { | ||||
|   var out = ' '; | ||||
|   var $lvl = it.level; | ||||
|   var $dataLvl = it.dataLevel; | ||||
|   var $schema = it.schema[$keyword]; | ||||
|   var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|   var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|   var $breakOnError = !it.opts.allErrors; | ||||
|   var $data = 'data' + ($dataLvl || ''); | ||||
|   var $valid = 'valid' + $lvl; | ||||
|   var $isData = it.opts.$data && $schema && $schema.$data, | ||||
|     $schemaValue; | ||||
|   if ($isData) { | ||||
|     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; | ||||
|     $schemaValue = 'schema' + $lvl; | ||||
|   } else { | ||||
|     $schemaValue = $schema; | ||||
|   } | ||||
|   if (($schema || $isData) && it.opts.uniqueItems !== false) { | ||||
|     if ($isData) { | ||||
|       out += ' var ' + ($valid) + '; if (' + ($schemaValue) + ' === false || ' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'boolean\') ' + ($valid) + ' = false; else { '; | ||||
|     } | ||||
|     out += ' var i = ' + ($data) + '.length , ' + ($valid) + ' = true , j; if (i > 1) { '; | ||||
|     var $itemType = it.schema.items && it.schema.items.type, | ||||
|       $typeIsArray = Array.isArray($itemType); | ||||
|     if (!$itemType || $itemType == 'object' || $itemType == 'array' || ($typeIsArray && ($itemType.indexOf('object') >= 0 || $itemType.indexOf('array') >= 0))) { | ||||
|       out += ' outer: for (;i--;) { for (j = i; j--;) { if (equal(' + ($data) + '[i], ' + ($data) + '[j])) { ' + ($valid) + ' = false; break outer; } } } '; | ||||
|     } else { | ||||
|       out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; '; | ||||
|       var $method = 'checkDataType' + ($typeIsArray ? 's' : ''); | ||||
|       out += ' if (' + (it.util[$method]($itemType, 'item', it.opts.strictNumbers, true)) + ') continue; '; | ||||
|       if ($typeIsArray) { | ||||
|         out += ' if (typeof item == \'string\') item = \'"\' + item; '; | ||||
|       } | ||||
|       out += ' if (typeof itemIndices[item] == \'number\') { ' + ($valid) + ' = false; j = itemIndices[item]; break; } itemIndices[item] = i; } '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|     if ($isData) { | ||||
|       out += '  }  '; | ||||
|     } | ||||
|     out += ' if (!' + ($valid) + ') {   '; | ||||
|     var $$outStack = $$outStack || []; | ||||
|     $$outStack.push(out); | ||||
|     out = ''; /* istanbul ignore else */ | ||||
|     if (it.createErrors !== false) { | ||||
|       out += ' { keyword: \'' + ('uniqueItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { i: i, j: j } '; | ||||
|       if (it.opts.messages !== false) { | ||||
|         out += ' , message: \'should NOT have duplicate items (items ## \' + j + \' and \' + i + \' are identical)\' '; | ||||
|       } | ||||
|       if (it.opts.verbose) { | ||||
|         out += ' , schema:  '; | ||||
|         if ($isData) { | ||||
|           out += 'validate.schema' + ($schemaPath); | ||||
|         } else { | ||||
|           out += '' + ($schema); | ||||
|         } | ||||
|         out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|       } | ||||
|       out += ' } '; | ||||
|     } else { | ||||
|       out += ' {} '; | ||||
|     } | ||||
|     var __err = out; | ||||
|     out = $$outStack.pop(); | ||||
|     if (!it.compositeRule && $breakOnError) { | ||||
|       /* istanbul ignore if */ | ||||
|       if (it.async) { | ||||
|         out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|       } else { | ||||
|         out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|       } | ||||
|     } else { | ||||
|       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|     } | ||||
|     out += ' } '; | ||||
|     if ($breakOnError) { | ||||
|       out += ' else { '; | ||||
|     } | ||||
|   } else { | ||||
|     if ($breakOnError) { | ||||
|       out += ' if (true) { '; | ||||
|     } | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
							
								
								
									
										482
									
								
								node_modules/ajv/lib/dotjs/validate.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										482
									
								
								node_modules/ajv/lib/dotjs/validate.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,482 @@ | ||||
| 'use strict'; | ||||
| module.exports = function generate_validate(it, $keyword, $ruleType) { | ||||
|   var out = ''; | ||||
|   var $async = it.schema.$async === true, | ||||
|     $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'), | ||||
|     $id = it.self._getId(it.schema); | ||||
|   if (it.opts.strictKeywords) { | ||||
|     var $unknownKwd = it.util.schemaUnknownRules(it.schema, it.RULES.keywords); | ||||
|     if ($unknownKwd) { | ||||
|       var $keywordsMsg = 'unknown keyword: ' + $unknownKwd; | ||||
|       if (it.opts.strictKeywords === 'log') it.logger.warn($keywordsMsg); | ||||
|       else throw new Error($keywordsMsg); | ||||
|     } | ||||
|   } | ||||
|   if (it.isTop) { | ||||
|     out += ' var validate = '; | ||||
|     if ($async) { | ||||
|       it.async = true; | ||||
|       out += 'async '; | ||||
|     } | ||||
|     out += 'function(data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; '; | ||||
|     if ($id && (it.opts.sourceCode || it.opts.processCode)) { | ||||
|       out += ' ' + ('/\*# sourceURL=' + $id + ' */') + ' '; | ||||
|     } | ||||
|   } | ||||
|   if (typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref)) { | ||||
|     var $keyword = 'false schema'; | ||||
|     var $lvl = it.level; | ||||
|     var $dataLvl = it.dataLevel; | ||||
|     var $schema = it.schema[$keyword]; | ||||
|     var $schemaPath = it.schemaPath + it.util.getProperty($keyword); | ||||
|     var $errSchemaPath = it.errSchemaPath + '/' + $keyword; | ||||
|     var $breakOnError = !it.opts.allErrors; | ||||
|     var $errorKeyword; | ||||
|     var $data = 'data' + ($dataLvl || ''); | ||||
|     var $valid = 'valid' + $lvl; | ||||
|     if (it.schema === false) { | ||||
|       if (it.isTop) { | ||||
|         $breakOnError = true; | ||||
|       } else { | ||||
|         out += ' var ' + ($valid) + ' = false; '; | ||||
|       } | ||||
|       var $$outStack = $$outStack || []; | ||||
|       $$outStack.push(out); | ||||
|       out = ''; /* istanbul ignore else */ | ||||
|       if (it.createErrors !== false) { | ||||
|         out += ' { keyword: \'' + ($errorKeyword || 'false schema') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; | ||||
|         if (it.opts.messages !== false) { | ||||
|           out += ' , message: \'boolean schema is false\' '; | ||||
|         } | ||||
|         if (it.opts.verbose) { | ||||
|           out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|         } | ||||
|         out += ' } '; | ||||
|       } else { | ||||
|         out += ' {} '; | ||||
|       } | ||||
|       var __err = out; | ||||
|       out = $$outStack.pop(); | ||||
|       if (!it.compositeRule && $breakOnError) { | ||||
|         /* istanbul ignore if */ | ||||
|         if (it.async) { | ||||
|           out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|         } else { | ||||
|           out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|         } | ||||
|       } else { | ||||
|         out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|       } | ||||
|     } else { | ||||
|       if (it.isTop) { | ||||
|         if ($async) { | ||||
|           out += ' return data; '; | ||||
|         } else { | ||||
|           out += ' validate.errors = null; return true; '; | ||||
|         } | ||||
|       } else { | ||||
|         out += ' var ' + ($valid) + ' = true; '; | ||||
|       } | ||||
|     } | ||||
|     if (it.isTop) { | ||||
|       out += ' }; return validate; '; | ||||
|     } | ||||
|     return out; | ||||
|   } | ||||
|   if (it.isTop) { | ||||
|     var $top = it.isTop, | ||||
|       $lvl = it.level = 0, | ||||
|       $dataLvl = it.dataLevel = 0, | ||||
|       $data = 'data'; | ||||
|     it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema)); | ||||
|     it.baseId = it.baseId || it.rootId; | ||||
|     delete it.isTop; | ||||
|     it.dataPathArr = [""]; | ||||
|     if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) { | ||||
|       var $defaultMsg = 'default is ignored in the schema root'; | ||||
|       if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg); | ||||
|       else throw new Error($defaultMsg); | ||||
|     } | ||||
|     out += ' var vErrors = null; '; | ||||
|     out += ' var errors = 0;     '; | ||||
|     out += ' if (rootData === undefined) rootData = data; '; | ||||
|   } else { | ||||
|     var $lvl = it.level, | ||||
|       $dataLvl = it.dataLevel, | ||||
|       $data = 'data' + ($dataLvl || ''); | ||||
|     if ($id) it.baseId = it.resolve.url(it.baseId, $id); | ||||
|     if ($async && !it.async) throw new Error('async schema in sync schema'); | ||||
|     out += ' var errs_' + ($lvl) + ' = errors;'; | ||||
|   } | ||||
|   var $valid = 'valid' + $lvl, | ||||
|     $breakOnError = !it.opts.allErrors, | ||||
|     $closingBraces1 = '', | ||||
|     $closingBraces2 = ''; | ||||
|   var $errorKeyword; | ||||
|   var $typeSchema = it.schema.type, | ||||
|     $typeIsArray = Array.isArray($typeSchema); | ||||
|   if ($typeSchema && it.opts.nullable && it.schema.nullable === true) { | ||||
|     if ($typeIsArray) { | ||||
|       if ($typeSchema.indexOf('null') == -1) $typeSchema = $typeSchema.concat('null'); | ||||
|     } else if ($typeSchema != 'null') { | ||||
|       $typeSchema = [$typeSchema, 'null']; | ||||
|       $typeIsArray = true; | ||||
|     } | ||||
|   } | ||||
|   if ($typeIsArray && $typeSchema.length == 1) { | ||||
|     $typeSchema = $typeSchema[0]; | ||||
|     $typeIsArray = false; | ||||
|   } | ||||
|   if (it.schema.$ref && $refKeywords) { | ||||
|     if (it.opts.extendRefs == 'fail') { | ||||
|       throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)'); | ||||
|     } else if (it.opts.extendRefs !== true) { | ||||
|       $refKeywords = false; | ||||
|       it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"'); | ||||
|     } | ||||
|   } | ||||
|   if (it.schema.$comment && it.opts.$comment) { | ||||
|     out += ' ' + (it.RULES.all.$comment.code(it, '$comment')); | ||||
|   } | ||||
|   if ($typeSchema) { | ||||
|     if (it.opts.coerceTypes) { | ||||
|       var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema); | ||||
|     } | ||||
|     var $rulesGroup = it.RULES.types[$typeSchema]; | ||||
|     if ($coerceToTypes || $typeIsArray || $rulesGroup === true || ($rulesGroup && !$shouldUseGroup($rulesGroup))) { | ||||
|       var $schemaPath = it.schemaPath + '.type', | ||||
|         $errSchemaPath = it.errSchemaPath + '/type'; | ||||
|       var $schemaPath = it.schemaPath + '.type', | ||||
|         $errSchemaPath = it.errSchemaPath + '/type', | ||||
|         $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType'; | ||||
|       out += ' if (' + (it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true)) + ') { '; | ||||
|       if ($coerceToTypes) { | ||||
|         var $dataType = 'dataType' + $lvl, | ||||
|           $coerced = 'coerced' + $lvl; | ||||
|         out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; var ' + ($coerced) + ' = undefined; '; | ||||
|         if (it.opts.coerceTypes == 'array') { | ||||
|           out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ') && ' + ($data) + '.length == 1) { ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + '; if (' + (it.util.checkDataType(it.schema.type, $data, it.opts.strictNumbers)) + ') ' + ($coerced) + ' = ' + ($data) + '; } '; | ||||
|         } | ||||
|         out += ' if (' + ($coerced) + ' !== undefined) ; '; | ||||
|         var arr1 = $coerceToTypes; | ||||
|         if (arr1) { | ||||
|           var $type, $i = -1, | ||||
|             l1 = arr1.length - 1; | ||||
|           while ($i < l1) { | ||||
|             $type = arr1[$i += 1]; | ||||
|             if ($type == 'string') { | ||||
|               out += ' else if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; '; | ||||
|             } else if ($type == 'number' || $type == 'integer') { | ||||
|               out += ' else if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' '; | ||||
|               if ($type == 'integer') { | ||||
|                 out += ' && !(' + ($data) + ' % 1)'; | ||||
|               } | ||||
|               out += ')) ' + ($coerced) + ' = +' + ($data) + '; '; | ||||
|             } else if ($type == 'boolean') { | ||||
|               out += ' else if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; '; | ||||
|             } else if ($type == 'null') { | ||||
|               out += ' else if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; '; | ||||
|             } else if (it.opts.coerceTypes == 'array' && $type == 'array') { | ||||
|               out += ' else if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; '; | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|         out += ' else {   '; | ||||
|         var $$outStack = $$outStack || []; | ||||
|         $$outStack.push(out); | ||||
|         out = ''; /* istanbul ignore else */ | ||||
|         if (it.createErrors !== false) { | ||||
|           out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \''; | ||||
|           if ($typeIsArray) { | ||||
|             out += '' + ($typeSchema.join(",")); | ||||
|           } else { | ||||
|             out += '' + ($typeSchema); | ||||
|           } | ||||
|           out += '\' } '; | ||||
|           if (it.opts.messages !== false) { | ||||
|             out += ' , message: \'should be '; | ||||
|             if ($typeIsArray) { | ||||
|               out += '' + ($typeSchema.join(",")); | ||||
|             } else { | ||||
|               out += '' + ($typeSchema); | ||||
|             } | ||||
|             out += '\' '; | ||||
|           } | ||||
|           if (it.opts.verbose) { | ||||
|             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|           } | ||||
|           out += ' } '; | ||||
|         } else { | ||||
|           out += ' {} '; | ||||
|         } | ||||
|         var __err = out; | ||||
|         out = $$outStack.pop(); | ||||
|         if (!it.compositeRule && $breakOnError) { | ||||
|           /* istanbul ignore if */ | ||||
|           if (it.async) { | ||||
|             out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|           } else { | ||||
|             out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|           } | ||||
|         } else { | ||||
|           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|         } | ||||
|         out += ' } if (' + ($coerced) + ' !== undefined) {  '; | ||||
|         var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData', | ||||
|           $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty'; | ||||
|         out += ' ' + ($data) + ' = ' + ($coerced) + '; '; | ||||
|         if (!$dataLvl) { | ||||
|           out += 'if (' + ($parentData) + ' !== undefined)'; | ||||
|         } | ||||
|         out += ' ' + ($parentData) + '[' + ($parentDataProperty) + '] = ' + ($coerced) + '; } '; | ||||
|       } else { | ||||
|         var $$outStack = $$outStack || []; | ||||
|         $$outStack.push(out); | ||||
|         out = ''; /* istanbul ignore else */ | ||||
|         if (it.createErrors !== false) { | ||||
|           out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \''; | ||||
|           if ($typeIsArray) { | ||||
|             out += '' + ($typeSchema.join(",")); | ||||
|           } else { | ||||
|             out += '' + ($typeSchema); | ||||
|           } | ||||
|           out += '\' } '; | ||||
|           if (it.opts.messages !== false) { | ||||
|             out += ' , message: \'should be '; | ||||
|             if ($typeIsArray) { | ||||
|               out += '' + ($typeSchema.join(",")); | ||||
|             } else { | ||||
|               out += '' + ($typeSchema); | ||||
|             } | ||||
|             out += '\' '; | ||||
|           } | ||||
|           if (it.opts.verbose) { | ||||
|             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|           } | ||||
|           out += ' } '; | ||||
|         } else { | ||||
|           out += ' {} '; | ||||
|         } | ||||
|         var __err = out; | ||||
|         out = $$outStack.pop(); | ||||
|         if (!it.compositeRule && $breakOnError) { | ||||
|           /* istanbul ignore if */ | ||||
|           if (it.async) { | ||||
|             out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|           } else { | ||||
|             out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|           } | ||||
|         } else { | ||||
|           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|         } | ||||
|       } | ||||
|       out += ' } '; | ||||
|     } | ||||
|   } | ||||
|   if (it.schema.$ref && !$refKeywords) { | ||||
|     out += ' ' + (it.RULES.all.$ref.code(it, '$ref')) + ' '; | ||||
|     if ($breakOnError) { | ||||
|       out += ' } if (errors === '; | ||||
|       if ($top) { | ||||
|         out += '0'; | ||||
|       } else { | ||||
|         out += 'errs_' + ($lvl); | ||||
|       } | ||||
|       out += ') { '; | ||||
|       $closingBraces2 += '}'; | ||||
|     } | ||||
|   } else { | ||||
|     var arr2 = it.RULES; | ||||
|     if (arr2) { | ||||
|       var $rulesGroup, i2 = -1, | ||||
|         l2 = arr2.length - 1; | ||||
|       while (i2 < l2) { | ||||
|         $rulesGroup = arr2[i2 += 1]; | ||||
|         if ($shouldUseGroup($rulesGroup)) { | ||||
|           if ($rulesGroup.type) { | ||||
|             out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers)) + ') { '; | ||||
|           } | ||||
|           if (it.opts.useDefaults) { | ||||
|             if ($rulesGroup.type == 'object' && it.schema.properties) { | ||||
|               var $schema = it.schema.properties, | ||||
|                 $schemaKeys = Object.keys($schema); | ||||
|               var arr3 = $schemaKeys; | ||||
|               if (arr3) { | ||||
|                 var $propertyKey, i3 = -1, | ||||
|                   l3 = arr3.length - 1; | ||||
|                 while (i3 < l3) { | ||||
|                   $propertyKey = arr3[i3 += 1]; | ||||
|                   var $sch = $schema[$propertyKey]; | ||||
|                   if ($sch.default !== undefined) { | ||||
|                     var $passData = $data + it.util.getProperty($propertyKey); | ||||
|                     if (it.compositeRule) { | ||||
|                       if (it.opts.strictDefaults) { | ||||
|                         var $defaultMsg = 'default is ignored for: ' + $passData; | ||||
|                         if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg); | ||||
|                         else throw new Error($defaultMsg); | ||||
|                       } | ||||
|                     } else { | ||||
|                       out += ' if (' + ($passData) + ' === undefined '; | ||||
|                       if (it.opts.useDefaults == 'empty') { | ||||
|                         out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' '; | ||||
|                       } | ||||
|                       out += ' ) ' + ($passData) + ' = '; | ||||
|                       if (it.opts.useDefaults == 'shared') { | ||||
|                         out += ' ' + (it.useDefault($sch.default)) + ' '; | ||||
|                       } else { | ||||
|                         out += ' ' + (JSON.stringify($sch.default)) + ' '; | ||||
|                       } | ||||
|                       out += '; '; | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } else if ($rulesGroup.type == 'array' && Array.isArray(it.schema.items)) { | ||||
|               var arr4 = it.schema.items; | ||||
|               if (arr4) { | ||||
|                 var $sch, $i = -1, | ||||
|                   l4 = arr4.length - 1; | ||||
|                 while ($i < l4) { | ||||
|                   $sch = arr4[$i += 1]; | ||||
|                   if ($sch.default !== undefined) { | ||||
|                     var $passData = $data + '[' + $i + ']'; | ||||
|                     if (it.compositeRule) { | ||||
|                       if (it.opts.strictDefaults) { | ||||
|                         var $defaultMsg = 'default is ignored for: ' + $passData; | ||||
|                         if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg); | ||||
|                         else throw new Error($defaultMsg); | ||||
|                       } | ||||
|                     } else { | ||||
|                       out += ' if (' + ($passData) + ' === undefined '; | ||||
|                       if (it.opts.useDefaults == 'empty') { | ||||
|                         out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' '; | ||||
|                       } | ||||
|                       out += ' ) ' + ($passData) + ' = '; | ||||
|                       if (it.opts.useDefaults == 'shared') { | ||||
|                         out += ' ' + (it.useDefault($sch.default)) + ' '; | ||||
|                       } else { | ||||
|                         out += ' ' + (JSON.stringify($sch.default)) + ' '; | ||||
|                       } | ||||
|                       out += '; '; | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|           var arr5 = $rulesGroup.rules; | ||||
|           if (arr5) { | ||||
|             var $rule, i5 = -1, | ||||
|               l5 = arr5.length - 1; | ||||
|             while (i5 < l5) { | ||||
|               $rule = arr5[i5 += 1]; | ||||
|               if ($shouldUseRule($rule)) { | ||||
|                 var $code = $rule.code(it, $rule.keyword, $rulesGroup.type); | ||||
|                 if ($code) { | ||||
|                   out += ' ' + ($code) + ' '; | ||||
|                   if ($breakOnError) { | ||||
|                     $closingBraces1 += '}'; | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|           if ($breakOnError) { | ||||
|             out += ' ' + ($closingBraces1) + ' '; | ||||
|             $closingBraces1 = ''; | ||||
|           } | ||||
|           if ($rulesGroup.type) { | ||||
|             out += ' } '; | ||||
|             if ($typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes) { | ||||
|               out += ' else { '; | ||||
|               var $schemaPath = it.schemaPath + '.type', | ||||
|                 $errSchemaPath = it.errSchemaPath + '/type'; | ||||
|               var $$outStack = $$outStack || []; | ||||
|               $$outStack.push(out); | ||||
|               out = ''; /* istanbul ignore else */ | ||||
|               if (it.createErrors !== false) { | ||||
|                 out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \''; | ||||
|                 if ($typeIsArray) { | ||||
|                   out += '' + ($typeSchema.join(",")); | ||||
|                 } else { | ||||
|                   out += '' + ($typeSchema); | ||||
|                 } | ||||
|                 out += '\' } '; | ||||
|                 if (it.opts.messages !== false) { | ||||
|                   out += ' , message: \'should be '; | ||||
|                   if ($typeIsArray) { | ||||
|                     out += '' + ($typeSchema.join(",")); | ||||
|                   } else { | ||||
|                     out += '' + ($typeSchema); | ||||
|                   } | ||||
|                   out += '\' '; | ||||
|                 } | ||||
|                 if (it.opts.verbose) { | ||||
|                   out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; | ||||
|                 } | ||||
|                 out += ' } '; | ||||
|               } else { | ||||
|                 out += ' {} '; | ||||
|               } | ||||
|               var __err = out; | ||||
|               out = $$outStack.pop(); | ||||
|               if (!it.compositeRule && $breakOnError) { | ||||
|                 /* istanbul ignore if */ | ||||
|                 if (it.async) { | ||||
|                   out += ' throw new ValidationError([' + (__err) + ']); '; | ||||
|                 } else { | ||||
|                   out += ' validate.errors = [' + (__err) + ']; return false; '; | ||||
|                 } | ||||
|               } else { | ||||
|                 out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; | ||||
|               } | ||||
|               out += ' } '; | ||||
|             } | ||||
|           } | ||||
|           if ($breakOnError) { | ||||
|             out += ' if (errors === '; | ||||
|             if ($top) { | ||||
|               out += '0'; | ||||
|             } else { | ||||
|               out += 'errs_' + ($lvl); | ||||
|             } | ||||
|             out += ') { '; | ||||
|             $closingBraces2 += '}'; | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   if ($breakOnError) { | ||||
|     out += ' ' + ($closingBraces2) + ' '; | ||||
|   } | ||||
|   if ($top) { | ||||
|     if ($async) { | ||||
|       out += ' if (errors === 0) return data;           '; | ||||
|       out += ' else throw new ValidationError(vErrors); '; | ||||
|     } else { | ||||
|       out += ' validate.errors = vErrors; '; | ||||
|       out += ' return errors === 0;       '; | ||||
|     } | ||||
|     out += ' }; return validate;'; | ||||
|   } else { | ||||
|     out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';'; | ||||
|   } | ||||
|  | ||||
|   function $shouldUseGroup($rulesGroup) { | ||||
|     var rules = $rulesGroup.rules; | ||||
|     for (var i = 0; i < rules.length; i++) | ||||
|       if ($shouldUseRule(rules[i])) return true; | ||||
|   } | ||||
|  | ||||
|   function $shouldUseRule($rule) { | ||||
|     return it.schema[$rule.keyword] !== undefined || ($rule.implements && $ruleImplementsSomeKeyword($rule)); | ||||
|   } | ||||
|  | ||||
|   function $ruleImplementsSomeKeyword($rule) { | ||||
|     var impl = $rule.implements; | ||||
|     for (var i = 0; i < impl.length; i++) | ||||
|       if (it.schema[impl[i]] !== undefined) return true; | ||||
|   } | ||||
|   return out; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user