You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding a Rule.required().assetRequired() validation works as expected when the image is a field (in an object). However, when it's an array member, this validation is not respected by TypeGen. Instead, it is always marked as optional (asset?: ...)
As you can observe, although both images are using the exact same field, only the one in the array (logos) has its asset marked as optional with asset?.
Expected behavior
TypeGen should respect the rule.required().assetRequired() on assets of images that are inside arrays.
Which versions of Sanity are you using?
@sanity/cli (global) 3.43.0 (up to date)
@sanity/asset-utils 1.3.0 (up to date)
@sanity/cli 3.43.0 (up to date)
@sanity/code-input 4.1.4 (up to date)
@sanity/color-input 3.1.1 (up to date)
@sanity/icons 2.11.8 (up to date)
@sanity/image-url 1.0.2 (up to date)
@sanity/preview-url-secret 1.6.13 (up to date)
@sanity/ui 2.1.12 (up to date)
@sanity/vision 3.43.0 (up to date)
sanity 3.43.0 (up to date)
Not sure why @sanity/cli is marked as global here. I am using Volta, not sure if that's any help. Running npm list -g:
Describe the bug
Adding a
Rule.required().assetRequired()
validation works as expected when the image is a field (in an object). However, when it's an array member, this validation is not respected by TypeGen. Instead, it is always marked as optional (asset?: ...
)To Reproduce
The following schema:
Running:
Produces the following type:
As you can observe, although both images are using the exact same field, only the one in the array (
logos
) has its asset marked as optional withasset?
.Expected behavior
TypeGen should respect the
rule.required().assetRequired()
on assets of images that are inside arrays.Which versions of Sanity are you using?
What operating system are you using?
Which versions of Node.js / npm are you running?
The text was updated successfully, but these errors were encountered: