Add validation to subflow instance env properties

pull/4632/head
Nick O'Leary 2024-03-27 19:08:25 +00:00
parent 014691346a
commit 19213434f9
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 16 additions and 1 deletions

View File

@ -1025,7 +1025,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",