refactor: strictDefaults option

master
Evgeny Poberezkin 2019-03-03 10:54:16 +00:00
parent e993bd6b4e
commit 38d1acddad
2 changed files with 13 additions and 16 deletions

View File

@ -1,13 +1,12 @@
{{## def.assignDefault:
{{? it.compositeRule }}
{{? it.opts.strictDefaults }}
{{ var $defaultMsg = 'default is ignored for: ' + $passData; }}
{{? it.opts.strictDefaults === 'log' }}
{{ it.logger.warn($defaultMsg); }}
{{??}}
{{ throw new Error($defaultMsg); }}
{{?}}
{{?}}
{{
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);
}
}}
{{??}}
if ({{=$passData}} === undefined
{{? it.opts.useDefaults == 'empty' }}

View File

@ -82,15 +82,13 @@
delete it.isTop;
it.dataPathArr = [undefined];
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);
}
}}
{{? it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults }}
{{ var $defaultMsg = 'default is ignored in the schema root'; }}
{{? it.opts.strictDefaults === 'log' }}
{{ it.logger.warn($defaultMsg); }}
{{??}}
{{ throw new Error($defaultMsg); }}
{{?}}
{{?}}
var vErrors = null; {{ /* don't edit, used in replace */ }}
var errors = 0; {{ /* don't edit, used in replace */ }}