Currently, e.g. in histohour.js, input validation is implemented for each param, required and optional, with a lot of repetitive code:
// optional fields
// extraParams
if(msg.params && msg.params.extraParams){
urlParams.push("extraParams="+msg.params.extraParams);
}else{
if(node.extraParams || node.extraParams!=""){
urlParams.push("extraParams="+ node.extraParams);
}
}
// sign
if(msg.params && msg.params.sign){
urlParams.push("sign="+msg.params.sign);
}else{
if(node.sign || node.sign!=""){
urlParams.push("sign="+ node.sign);
}
}
This should be replaced by a generic method, to which you pass: the full input object and with a params setting or config object, the method should validate if input object complies to paramsConfig object.
Currently, e.g. in histohour.js, input validation is implemented for each param, required and optional, with a lot of repetitive code:
// optional fields
// extraParams
if(msg.params && msg.params.extraParams){
urlParams.push("extraParams="+msg.params.extraParams);
}else{
if(node.extraParams || node.extraParams!=""){
urlParams.push("extraParams="+ node.extraParams);
}
}
// sign
if(msg.params && msg.params.sign){
urlParams.push("sign="+msg.params.sign);
}else{
if(node.sign || node.sign!=""){
urlParams.push("sign="+ node.sign);
}
}
This should be replaced by a generic method, to which you pass: the full input object and with a params setting or config object, the method should validate if input object complies to paramsConfig object.