Skip to content

Replace input validation of url params by generic validation method #1

@remkohdev

Description

@remkohdev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions