Skip to content

Commit

Permalink
allow default body to satisfy required (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
sserrata authored Jan 23, 2025
1 parent 70a61b1 commit 64f8f65
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function App({
...props
}: any): JSX.Element {
const prismTheme = usePrismTheme();
const [code, setCode] = React.useState(children);
const [code, setCode] = React.useState(children.replace(/\n$/, ""));

useEffect(() => {
action(setStringRawBody(code));
Expand All @@ -76,15 +76,17 @@ function App({
})}
>
<LiveProvider
code={children.replace(/\n$/, "")}
code={code}
transformCode={transformCode ?? ((code) => `${code};`)}
theme={prismTheme}
language={language}
{...props}
>
<Controller
control={control}
rules={{ required: isRequired ? "This field is required" : false }}
rules={{
required: isRequired && !code ? "This field is required" : false,
}}
name="requestBody"
render={({ field: { onChange, name } }) => (
<LiveComponent
Expand Down

0 comments on commit 64f8f65

Please sign in to comment.