Skip to content

Commit

Permalink
fix: spectra simulation options validation
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-musallam committed Mar 22, 2024
1 parent be686ef commit 988dfec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/component/panels/spectrumSimulation/SpectrumSimulation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ import SpectrumSimulationPreferences, {
import SpectrumSimulationSimpleOptions from './SpectrumSimulationSimpleOptions';
import { SpinSystemTable } from './SpinSystemTable';

const optionsSchema = Yup.object({
lineWidth: Yup.number().min(0.1).required(),
});

const optionsValidationSchema = Yup.object({
options: optionsSchema,
});

const validationSchema = Yup.object({
data: Yup.array().of(
Yup.array().of(
Expand All @@ -34,6 +42,7 @@ const validationSchema = Yup.object({
}),
),
),
options: optionsSchema,
});

export default function SpectrumSimulation() {
Expand Down Expand Up @@ -110,6 +119,7 @@ export default function SpectrumSimulation() {
// eslint-disable-next-line @typescript-eslint/no-empty-function
onSubmit={() => {}}
innerRef={formRef}
validationSchema={optionsValidationSchema}
>
{({ values }) => (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export default function SpectrumSimulationSimpleOptions({
textAlign: 'center',
},
}}
step={0.1}
min={0.1}
/>
<span style={{ padding: '0 5px' }}>Hz</span>
</Label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function SpinSystemTable(props: SpinSystemTableProps) {
},
Header: () => (
<span>
J<sub>{label}-</sub>(Hz)
J<sub>{label}-X</sub>(Hz)
</span>
),
});
Expand Down

0 comments on commit 988dfec

Please sign in to comment.