Skip to content

Commit

Permalink
fix check oneof
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfq committed Jul 30, 2024
1 parent de5e70e commit 11b6a0b
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/components/inspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ const NodeInspector: FC = () => {
const arg = def.args?.find((a) => a.oneof && v.startsWith(a.oneof));
if (arg) {
const argName = `args.${arg.name}`;
if (!checkOneof(getFieldValue(argName), value)) {
if (!isFieldValidating(argName)) {
setFieldValue(`input.${i}`, value);
validateFields([argName]);
}
if (!isFieldValidating(argName)) {
setFieldValue(`input.${i}`, value);
validateFields([argName]);
}
if (!checkOneof(getFieldValue(argName) ?? "", value)) {
return Promise.reject(
new Error(
t("node.oneof.error", {
Expand All @@ -354,9 +354,6 @@ const NodeInspector: FC = () => {
)
);
} else {
if (!isFieldValidating(argName)) {
validateFields([argName]);
}
return Promise.resolve();
}
}
Expand Down Expand Up @@ -419,11 +416,11 @@ const NodeInspector: FC = () => {
);
}
const inputName = `input.${idx}`;
if (!checkOneof(getFieldValue(inputName), value)) {
if (!isFieldValidating(inputName)) {
setFieldValue(`args.${v.name}`, value);
validateFields([inputName]);
}
if (!isFieldValidating(inputName)) {
setFieldValue(`args.${v.name}`, value);
validateFields([inputName]);
}
if (!checkOneof(getFieldValue(inputName) ?? "", value)) {
return Promise.reject(
new Error(
t("node.oneof.error", {
Expand All @@ -434,9 +431,6 @@ const NodeInspector: FC = () => {
)
);
} else {
if (!isFieldValidating(inputName)) {
validateFields([inputName]);
}
return Promise.resolve();
}
},
Expand Down

0 comments on commit 11b6a0b

Please sign in to comment.