Skip to content

Commit

Permalink
validation allows an empty elements array for new stage
Browse files Browse the repository at this point in the history
  • Loading branch information
christabusho committed Jul 12, 2024
1 parent 343fb84 commit 9822b82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/editor/components/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function CodeEditor() {
} else {
setCode(value)
}
}, [])
}, [defaultTreatment])

function handleChange(evn: any) {
let entry = evn.target.value
Expand Down
15 changes: 10 additions & 5 deletions src/app/editor/components/EditStage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,17 @@ export function EditStage({
// if (watch('discussion') !== null) inputs.discussion = watch('discussion')
// if (watch('desc') !== "") inputs.desc = watch('desc')
// if (watch('elements') !== null) inputs.elements = watch('elements')
const result = stageSchema.safeParse( { ...inputs, elements: [] })
console.log("stageIndex",stageIndex);
const result = stageSchema.safeParse(inputs)
if (!result.success) {
console.log("Error message below:");
console.error(result.error.errors);
return;
const parsedError = result.error.errors;
if (parsedError[0].message === 'Array must contain at least 1 element(s)' && stageIndex === -1) {
// do nothing --> ignore the error
} else {
console.error("Error described below:");
console.error(result.error.errors);
return;
}
}

if (stageIndex === -1) {
Expand Down

0 comments on commit 9822b82

Please sign in to comment.