Refactor validateNode function in reactflowUtils.ts

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-21 16:39:37 -03:00
commit 60a83d1f6a

View file

@ -313,14 +313,17 @@ export function validateNode(node: NodeType, edges: Edge[]): Array<string> {
) { ) {
if (hasDuplicateKeys(template[t].value)) if (hasDuplicateKeys(template[t].value))
errors.push( errors.push(
`${type} (${getFieldTitle( `${displayName || type} (${getFieldTitle(
template, template,
t t
)}) contains duplicate keys with the same values.` )}) contains duplicate keys with the same values.`
); );
if (hasEmptyKey(template[t].value)) if (hasEmptyKey(template[t].value))
errors.push( errors.push(
`${type} (${getFieldTitle(template, t)}) field must not be empty.` `${displayName || type} (${getFieldTitle(
template,
t
)}) field must not be empty.`
); );
} }
return errors; return errors;