43 lines
1021 B
Plaintext
43 lines
1021 B
Plaintext
{{
|
|
var $data = 'data' + (it.dataLevel || '')
|
|
, $min = it.schema['x-range'][0]
|
|
, $max = it.schema['x-range'][1]
|
|
, $exclusive = !!it.schema.exclusiveRange
|
|
, $gt = $exclusive ? '>' : '>='
|
|
, $lt = $exclusive ? '<' : '<='
|
|
, $lvl = it.level
|
|
, $err = 'err' + $lvl;
|
|
}}
|
|
|
|
var minOk{{=$lvl}} = {{=$data}} {{=$gt}} {{=$min}};
|
|
var valid{{=$lvl}} = minOk{{=$lvl}} && {{=$data}} {{=$lt}} {{=$max}};
|
|
|
|
if (!valid{{=$lvl}}) {
|
|
var {{=$err}};
|
|
if (minOk{{=$lvl}}) {
|
|
{{=$err}} = {
|
|
keyword: 'x-range',
|
|
message: 'should be {{=$lt}} {{=$max}}',
|
|
params: {
|
|
comparison: '{{=$lt}}',
|
|
limit: {{=$max}},
|
|
exclusive: {{=$exclusive}}
|
|
}
|
|
};
|
|
} else {
|
|
{{=$err}} = {
|
|
keyword: 'x-range',
|
|
message: 'should be {{=$gt}} {{=$min}}',
|
|
params: {
|
|
comparison: '{{=$gt}}',
|
|
limit: {{=$min}},
|
|
exclusive: {{=$exclusive}}
|
|
}
|
|
};
|
|
}
|
|
|
|
errors++;
|
|
if (vErrors) vErrors[vErrors.length] = {{=$err}};
|
|
else vErrors = [{{=$err}}];
|
|
}
|