Improve validation by applying refactor
This commit is contained in:
parent
153a792fcb
commit
e81a16ce0d
@ -5,9 +5,7 @@ module.exports = class AggregationMapConfig extends MapConfig {
|
||||
constructor (config, datasource) {
|
||||
super(config, datasource);
|
||||
|
||||
aggregationValidator(this)('resolution', createNumberValidator(this));
|
||||
aggregationValidator(this)('placement', createIncludesValueValidator(this, Aggregation.PLACEMENTS));
|
||||
aggregationValidator(this)('threshold', createNumberValidator(this));
|
||||
this.validate();
|
||||
}
|
||||
|
||||
isAggregationMapConfig () {
|
||||
@ -51,16 +49,12 @@ module.exports = class AggregationMapConfig extends MapConfig {
|
||||
return aggregation;
|
||||
}
|
||||
|
||||
validateProperty (prop, validator) {
|
||||
for (let index = 0; index < this.getLayers().length; index++) {
|
||||
const aggregation = this.getAggregation(index);
|
||||
validate () {
|
||||
const validator = aggregationValidator(this);
|
||||
|
||||
if (aggregation === undefined || aggregation[prop] === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
validator(aggregation[prop], prop, index);
|
||||
}
|
||||
validator('resolution', createNumberValidator(this));
|
||||
validator('placement', createIncludesValueValidator(this, Aggregation.PLACEMENTS));
|
||||
validator('threshold', createNumberValidator(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user