mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Ensure property validation is backwards compatible
This commit is contained in:
@@ -128,7 +128,7 @@ RED.editor = (function() {
|
||||
* @param definition - the node property definitions (either def.defaults or def.creds)
|
||||
* @param property - the property name being validated
|
||||
* @param value - the property value being validated
|
||||
* @returns {boolean} whether the node proprty is valid
|
||||
* @returns {boolean|string} whether the node proprty is valid. `true`: valid `false|String`: invalid
|
||||
*/
|
||||
function validateNodeProperty(node,definition,property,value) {
|
||||
var valid = true;
|
||||
@@ -165,6 +165,10 @@ RED.editor = (function() {
|
||||
if ((definition[property].validate.length === 2) &&
|
||||
((typeof valid) === "string")) {
|
||||
return valid;
|
||||
} else {
|
||||
// Otherwise, a 2.x returns a truth-like/false-like value that
|
||||
// we should cooerce to a boolean.
|
||||
valid = !!valid
|
||||
}
|
||||
} catch(err) {
|
||||
console.log("Validation error:",node.type,node.id,"property: "+property,"value:",value,err);
|
||||
|
Reference in New Issue
Block a user