Skip to content

Commit

Permalink
fix(schema-extraction): check for _required field in validation rules
Browse files Browse the repository at this point in the history
  • Loading branch information
sgulseth committed Mar 29, 2024
1 parent 5756753 commit aead6d9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/@sanity/schema/src/sanity/extractSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,19 @@ function isFieldRequired(field: ObjectField): boolean {
},
},
) as Rule

if (typeof rule === 'function') {
rule(proxy)
if (required) {
return true
}
}

if (typeof rule === 'object' && rule !== null && '_required' in rule) {
if (rule._required === 'required') {
return true
}
}
}

return false
Expand Down

0 comments on commit aead6d9

Please sign in to comment.