Skip to content

Commit

Permalink
Only validating custom parameters if algorithm has been selected (#2005)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiehewitt15 authored Nov 14, 2023
1 parent b5b3137 commit f39ddf9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/components/Publish/_validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ const validationMetadata = {
.required('Required')
.isTrue('Please agree to the Terms and Conditions.'),
usesConsumerParameters: Yup.boolean(),
consumerParameters: Yup.array().when('usesConsumerParameters', {
is: true,
then: Yup.array()
.of(Yup.object().shape(validationConsumerParameters))
.required('Required'),
otherwise: Yup.array()
.nullable()
.transform((value) => value || null)
consumerParameters: Yup.array().when('type', {
is: 'algorithm',
then: Yup.array().when('usesConsumerParameters', {
is: true,
then: Yup.array()
.of(Yup.object().shape(validationConsumerParameters))
.required('Required'),
otherwise: Yup.array()
.nullable()
.transform((value) => value || null)
})
})
}

Expand Down

1 comment on commit f39ddf9

@vercel
Copy link

@vercel vercel bot commented on f39ddf9 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.