Merge pull request #4632 from node-red/4625-sf-env-err-handling

Add validation and error handling on subflow instance properties
This commit is contained in:
Nick O'Leary
2024-03-28 11:10:28 +00:00
committed by GitHub
2 changed files with 27 additions and 4 deletions

View File

@@ -1029,7 +1029,22 @@ RED.nodes = (function() {
RED.nodes.registerType("subflow:"+sf.id, {
defaults:{
name:{value:""},
env:{value:[]}
env:{value:[], validate: function(value) {
const errors = []
if (value) {
value.forEach(env => {
const r = RED.utils.validateTypedProperty(env.value, env.type)
if (r !== true) {
errors.push(env.name+': '+r)
}
})
}
if (errors.length === 0) {
return true
} else {
return errors
}
}}
},
icon: function() { return sf.icon||"subflow.svg" },
category: sf.category || "subflows",