Hi, I'm struggling with validation of two fields. My use-case is; I have two fields. Field A is for internal links and field B is for external links. I would like to show an error if both fields are filed out.
My schema is as follows:
{
title: "Artikkel",
name: "article",
type: "reference",
to: [{ type: articleDocument.name }],
description: "Lenke til en artikkel på Löplabbet",
validation: (_Rule_: _any_) =>
_Rule_.custom((_context_: _any_) =>
_context_.article && _context_.url ? true : "Du kan ikke lenke til både artikkel og ekstern URL"
),
},
{
title: "URL",
name: "url",
type: "string",
description: "Lenke til en ekstern side",
validation: (_Rule_: _any_) =>
_Rule_.custom((_context_: _any_) =>
_context_.url && _context_.article ? true : "Du kan ikke lenke til både ekstern URL og artikkel"
),
},
This shows a validation error message if both fields are in use, but I'm not able to publish. And the publish button shows this error: There are validation errors that need to be fixed before this document can be published.