@sanity/validation 3.9.1-purple-fairy.58 → 3.9.1-windTestInit.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.esm.js +20 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/util/requestIdleCallback.ts +2 -2
- package/src/validateDocument.ts +30 -0
package/src/validateDocument.ts
CHANGED
|
@@ -210,6 +210,36 @@ function validateItemObservable({
|
|
|
210
210
|
)
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
// markDefs also do no run nested validation if the parent object is undefined
|
|
214
|
+
// for a similar reason to arrays
|
|
215
|
+
const shouldRunNestedValidationForMarkDefs =
|
|
216
|
+
isPortableTextTextBlock(value) && value.markDefs?.length && isBlockSchemaType(type)
|
|
217
|
+
|
|
218
|
+
if (shouldRunNestedValidationForMarkDefs) {
|
|
219
|
+
const [spanChildrenField] = type.fields
|
|
220
|
+
const spanType = spanChildrenField.type.of.find(isSpanSchemaType)
|
|
221
|
+
|
|
222
|
+
const annotations = (spanType?.annotations || []).reduce<Map<string, SchemaType>>(
|
|
223
|
+
(acc, annotationType) => {
|
|
224
|
+
acc.set(annotationType.name, annotationType)
|
|
225
|
+
return acc
|
|
226
|
+
},
|
|
227
|
+
new Map()
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
nestedChecks = nestedChecks.concat(
|
|
231
|
+
(value.markDefs || []).map((markDef) =>
|
|
232
|
+
validateItemObservable({
|
|
233
|
+
...restOfContext,
|
|
234
|
+
parent: value,
|
|
235
|
+
value: markDef,
|
|
236
|
+
path: path.concat(['markDefs', {_key: markDef._key}]),
|
|
237
|
+
type: annotations.get(markDef._type),
|
|
238
|
+
})
|
|
239
|
+
)
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
|
|
213
243
|
return defer(() => merge([...selfChecks, ...nestedChecks])).pipe(
|
|
214
244
|
mergeMap((validateNode) => concat(idle(), validateNode), 40),
|
|
215
245
|
mergeAll(),
|