twitst4tz

twitter statistics web application
Log | Files | Refs | README | LICENSE

oneOf.jst (1150B)


      1 {{# def.definitions }}
      2 {{# def.errors }}
      3 {{# def.setupKeyword }}
      4 {{# def.setupNextLevel }}
      5 
      6 {{
      7   var $currentBaseId = $it.baseId
      8     , $prevValid = 'prevValid' + $lvl
      9     , $passingSchemas = 'passingSchemas' + $lvl;
     10 }}
     11 
     12 var {{=$errs}} = errors
     13   , {{=$prevValid}} = false
     14   , {{=$valid}} = false
     15   , {{=$passingSchemas}} = null;
     16 
     17 {{# def.setCompositeRule }}
     18 
     19 {{~ $schema:$sch:$i }}
     20   {{? {{# def.nonEmptySchema:$sch }} }}
     21     {{
     22       $it.schema = $sch;
     23       $it.schemaPath = $schemaPath + '[' + $i + ']';
     24       $it.errSchemaPath = $errSchemaPath + '/' + $i;
     25     }}
     26 
     27     {{# def.insertSubschemaCode }}
     28   {{??}}
     29     var {{=$nextValid}} = true;
     30   {{?}}
     31 
     32   {{? $i }}
     33     if ({{=$nextValid}} && {{=$prevValid}}) {
     34       {{=$valid}} = false;
     35       {{=$passingSchemas}} = [{{=$passingSchemas}}, {{=$i}}];
     36     } else {
     37     {{ $closingBraces += '}'; }}
     38   {{?}}
     39 
     40     if ({{=$nextValid}}) {
     41       {{=$valid}} = {{=$prevValid}} = true;
     42       {{=$passingSchemas}} = {{=$i}};
     43     }
     44 {{~}}
     45 
     46 {{# def.resetCompositeRule }}
     47 
     48 {{= $closingBraces }}
     49 
     50 if (!{{=$valid}}) {
     51   {{# def.extraError:'oneOf' }}
     52 } else {
     53   {{# def.resetErrors }}
     54 {{? it.opts.allErrors }} } {{?}}