@sanity/schema 5.10.0-next.15 → 5.10.0-next.17
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/_internal.js +12 -6
- package/lib/_internal.js.map +1 -1
- package/package.json +5 -5
package/lib/_internal.js
CHANGED
|
@@ -1035,7 +1035,8 @@ const builtinTypes = [
|
|
|
1035
1035
|
CROSS_DATASET_REFERENCE_INVALID: "cross-dataset-reference-invalid",
|
|
1036
1036
|
GLOBAL_DOCUMENT_REFERENCE_INVALID: "global-document-reference-invalid",
|
|
1037
1037
|
DEPRECATED_BLOCKEDITOR_KEY: "schema-deprecated-blockeditor-key",
|
|
1038
|
-
STANDALONE_BLOCK_TYPE: "schema-standalone-block-type"
|
|
1038
|
+
STANDALONE_BLOCK_TYPE: "schema-standalone-block-type",
|
|
1039
|
+
FIELD_TYPE_IS_DOCUMENT: "schema-field-type-is-document"
|
|
1039
1040
|
};
|
|
1040
1041
|
function createValidationResult(severity, message, helpId) {
|
|
1041
1042
|
if (helpId && !Object.keys(HELP_IDS).some((id) => HELP_IDS[id] === helpId))
|
|
@@ -1769,7 +1770,7 @@ function validateFieldName(name) {
|
|
|
1769
1770
|
)
|
|
1770
1771
|
];
|
|
1771
1772
|
}
|
|
1772
|
-
function validateField(field,
|
|
1773
|
+
function validateField(field, visitorContext) {
|
|
1773
1774
|
if (!isPlainObject(field))
|
|
1774
1775
|
return [
|
|
1775
1776
|
error(
|
|
@@ -1780,7 +1781,12 @@ function validateField(field, _visitorContext) {
|
|
|
1780
1781
|
const problems = [];
|
|
1781
1782
|
return problems.push(
|
|
1782
1783
|
..."name" in field ? validateFieldName(field.name) : [error("Missing field name", HELP_IDS.OBJECT_FIELD_NAME_INVALID)]
|
|
1783
|
-
), problems.push(...validateComponent(field)), problems
|
|
1784
|
+
), problems.push(...validateComponent(field)), field.type && typeof field.type == "string" && visitorContext.getType(field.type)?.type === "document" && problems.push(
|
|
1785
|
+
warning(
|
|
1786
|
+
`The type "${field.type}" is a document type and should not be used as a field type directly. Use a "reference" if you want to create a link to the document, or use "object" if you want to embed fields inline.`,
|
|
1787
|
+
HELP_IDS.FIELD_TYPE_IS_DOCUMENT
|
|
1788
|
+
)
|
|
1789
|
+
), problems;
|
|
1784
1790
|
}
|
|
1785
1791
|
function getDuplicateFields(array2) {
|
|
1786
1792
|
const dupes = {};
|
|
@@ -1849,7 +1855,7 @@ var object = (typeDef, visitorContext) => {
|
|
|
1849
1855
|
return {
|
|
1850
1856
|
name,
|
|
1851
1857
|
...fieldType,
|
|
1852
|
-
_problems: validateField(field).concat(_problems || [])
|
|
1858
|
+
_problems: validateField(field, visitorContext).concat(_problems || [])
|
|
1853
1859
|
};
|
|
1854
1860
|
}),
|
|
1855
1861
|
_problems: problems
|
|
@@ -1875,7 +1881,7 @@ var object = (typeDef, visitorContext) => {
|
|
|
1875
1881
|
return {
|
|
1876
1882
|
name,
|
|
1877
1883
|
...fieldType,
|
|
1878
|
-
_problems: validateField(field).concat(_problems || [])
|
|
1884
|
+
_problems: validateField(field, visitorContext).concat(_problems || [])
|
|
1879
1885
|
};
|
|
1880
1886
|
}),
|
|
1881
1887
|
_problems: problems
|
|
@@ -2005,7 +2011,7 @@ var image = (typeDef, visitorContext) => {
|
|
|
2005
2011
|
return {
|
|
2006
2012
|
name,
|
|
2007
2013
|
...fieldType,
|
|
2008
|
-
_problems: validateField(field).concat(_problems || [])
|
|
2014
|
+
_problems: validateField(field, visitorContext).concat(_problems || [])
|
|
2009
2015
|
};
|
|
2010
2016
|
}),
|
|
2011
2017
|
_problems: problems
|