Check required prop for each case instead of top level

This commit is contained in:
GogoVega 2024-06-28 14:15:51 +02:00
parent 19a8fa09a8
commit 2464d9ad95
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B

View File

@ -148,26 +148,21 @@ RED.editor = (function() {
((typeof definition[property].label) == "string")) {
label = definition[property].label;
}
if ("required" in definition[property]) {
if (definition[property].required) {
valid = value !== "";
if (!valid && label) {
return RED._("validator.errors.missing-required-prop", {
prop: label
});
}
} else {
if ("required" in definition[property] && definition[property].required) {
valid = value !== "";
if (!valid && label) {
return RED._("validator.errors.missing-required-prop", {
prop: label
});
}
}
if (valid && "validate" in definition[property]) {
if (definition[property].hasOwnProperty("required") &&
definition[property].required === false) {
if (value === "") {
return true;
}
}
} else {
if (value === "") {
return true;
}
}
if (valid && "validate" in definition[property]) {
try {
var opt = {};
if (label) {
@ -194,6 +189,11 @@ RED.editor = (function() {
});
}
} else if (valid) {
if (definition[property].hasOwnProperty("required") && definition[property].required === false) {
if (value === "") {
return true;
}
}
// If the validator is not provided in node property => Check if the input has a validator
if ("category" in node._def) {
const isConfig = node._def.category === "config";