Skip to content

Commit

Permalink
πŸ› Properly feature flag issue #1438
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandolucchesi committed Jan 19, 2023
1 parent ae4b53e commit 1bef16b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions studio/schemas/objects/linkSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ const LinkField = {
Rule.custom(async (value: any, context: ValidationContext) => {
const { parent, document } = context as { parent: LinkSelector; document: { _lang?: string } }
if (parent.linkToOtherLanguage) return true
const referenceLang = await client.fetch(
/* groq */ `*[_id == $id][0]{"lang": coalesce(content->_lang, _lang)}.lang`,
{
id: value._ref,
},
)
if (Flags.IS_DEV && document._lang !== referenceLang)
return 'Reference must have the same language as the document'
if (Flags.IS_DEV && value._ref) {
const referenceLang = await client.fetch(
/* groq */ `*[_id == $id][0]{"lang": coalesce(content->_lang, _lang)}.lang`,
{
id: value._ref,
},
)
if (document._lang !== referenceLang) return 'Reference must have the same language as the document'
}
return validateInternalOrExternalUrl(value, parent.url)
}),
to: defaultReferenceTargets,
Expand Down

0 comments on commit 1bef16b

Please sign in to comment.