Skip to content

Commit b760388

Browse files
committed
#3398 Fixed default validation for background gradient
1 parent a5867d4 commit b760388

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

studio/schemas/documents/header/sharedHeaderFields.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,13 @@ const backgroundGradient = {
231231
{ title: 'Light', value: 'light' },
232232
],
233233
},
234-
validation: (Rule: Rule) => Rule.required(),
234+
validation: (Rule: Rule) =>
235+
Rule.custom((value: string, context: ValidationContext) => {
236+
const { parent } = context as unknown as DocumentType
237+
if (parent?.heroType === HeroTypes.BACKGROUND_IMAGE && !value)
238+
return 'Field is required'
239+
return true
240+
}),
235241
hidden: ({ parent }: DocumentType) => {
236242
return parent?.heroType !== HeroTypes.BACKGROUND_IMAGE
237243
}

0 commit comments

Comments
 (0)