3 {{# def.setupKeyword }}
6 {{? $breakOnError }} if (true) { {{?}}
10 {{? it.opts.format === false }}{{# def.skipFormat }}{{?}}
16 {{## def.$dataCheckFormat:
17 {{# def.$dataNotType:'string' }}
18 ({{? $unknownFormats === true || $allowUnknown }}
19 ({{=$schemaValue}} && !{{=$format}}
21 && self._opts.unknownFormats.indexOf({{=$schemaValue}}) == -1
24 ({{=$format}} && !(typeof {{=$format}} == 'function'
26 (async{{=$lvl}} ? {{=it.yieldAwait}} {{=$format}}({{=$data}}) : {{=$format}}({{=$data}}))
28 {{=$format}}({{=$data}})
30 : {{=$format}}.test({{=$data}}))))
35 var $formatRef = 'formats' + it.util.getProperty($schema);
36 if ($isObject) $formatRef += '.validate';
38 {{? typeof $format == 'function' }}
39 {{=$formatRef}}({{=$data}})
41 {{=$formatRef}}.test({{=$data}})
47 var $unknownFormats = it.opts.unknownFormats
48 , $allowUnknown = Array.isArray($unknownFormats);
52 {{ var $format = 'format' + $lvl; }}
53 var {{=$format}} = formats[{{=$schemaValue}}];
54 var isObject{{=$lvl}} = typeof {{=$format}} == 'object'
55 && !({{=$format}} instanceof RegExp)
56 && {{=$format}}.validate;
57 if (isObject{{=$lvl}}) {
59 var async{{=$lvl}} = {{=$format}}.async;
61 {{=$format}} = {{=$format}}.validate;
63 if ({{# def.$dataCheckFormat }}) {
65 {{ var $format = it.formats[$schema]; }}
67 {{? $unknownFormats === true || ($allowUnknown && $unknownFormats.indexOf($schema) == -1) }}
68 {{ throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"'); }}
72 console.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
73 if ($unknownFormats !== 'ignore')
74 console.warn('In the next major version it will throw exception. See option unknownFormats for more information');
81 var $isObject = typeof $format == 'object'
82 && !($format instanceof RegExp)
85 var $async = $format.async === true;
86 $format = $format.validate;
91 if (!it.async) throw new Error('async format in sync schema');
92 var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
94 if (!({{=it.yieldAwait}} {{=$formatRef}}({{=$data}}))) {
96 if (!{{# def.checkFormat }}) {
99 {{# def.error:'format' }}
100 } {{? $breakOnError }} else { {{?}}