Sha256: 78ac51a348a64267939c2134d5ba131cf818e1b644f0e617d6dacf607c0ef208

Contents?: true

Size: 1.52 KB

Versions: 49

Compression:

Stored size: 1.52 KB

Contents

{{# def.definitions }}
{{# def.errors }}
{{# def.setupKeyword }}
{{# def.setupNextLevel }}


{{## def.validateIf:
  {{# def.setCompositeRule }}
  {{ $it.createErrors = false; }}
  {{# def._validateSwitchRule:if }}
  {{ $it.createErrors = true; }}
  {{# def.resetCompositeRule }}
  {{=$ifPassed}} = valid{{=$it.level}};
#}}

{{## def.validateThen:
  {{? typeof $sch.then == 'boolean' }}
    {{? $sch.then === false }}
      {{# def.error:'switch' }}
    {{?}}
    var valid{{=$it.level}} = {{= $sch.then }};
  {{??}}
    {{# def._validateSwitchRule:then }}
  {{?}}
#}}

{{## def._validateSwitchRule:_clause:
  {{
    $it.schema = $sch._clause;
    $it.schemaPath = $schemaPath + '[' + $caseIndex + ']._clause';
    $it.errSchemaPath = $errSchemaPath + '/' + $caseIndex + '/_clause';
  }}
  {{# def.insertSubschemaCode }}
#}}

{{## def.switchCase:
  {{? $sch.if && {{# def.nonEmptySchema:$sch.if }} }}
    var {{=$errs}} = errors;
    {{# def.validateIf }}
    if ({{=$ifPassed}}) {
      {{# def.validateThen }}  
    } else {
      {{# def.resetErrors }}
    }
  {{??}}
    {{=$ifPassed}} = true;
    {{# def.validateThen }}
  {{?}}
#}}


{{
  var $ifPassed = 'ifPassed' + it.level
    , $currentBaseId = $it.baseId
    , $shouldContinue;
}}
var {{=$ifPassed}};

{{~ $schema:$sch:$caseIndex }}
  {{? $caseIndex && !$shouldContinue }}
    if (!{{=$ifPassed}}) {
    {{ $closingBraces+= '}'; }}
  {{?}}

  {{# def.switchCase }}
  {{ $shouldContinue = $sch.continue }}
{{~}}

{{= $closingBraces }}

var {{=$valid}} = valid{{=$it.level}};

{{# def.cleanUp }}

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/ajv-keywords/keywords/dot/switch.jst
ilog-0.4.0 node_modules/ajv-keywords/keywords/dot/switch.jst
ilog-0.3.3 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-18.0.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.21.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.20.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.19.1 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.19.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.18.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.17.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.16.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.15.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.14.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.13.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.12.2 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.12.1 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.12.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.11.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.10.0 node_modules/ajv-keywords/keywords/dot/switch.jst
govuk_publishing_components-17.9.0 node_modules/ajv-keywords/keywords/dot/switch.jst