@sanity/validation 6.24.0-next.8 → 7.0.0-next-major.20261111083413
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/README.md +0 -7
- package/lib/_internal.d.ts +2 -7
- package/lib/_internal.js +2 -3
- package/lib/_internal.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/{validateDocument-DESiHtPx.d.ts → validateDocument-Bqq2KtlY.d.ts} +5 -36
- package/lib/{validateDocument-B0K7YlIj.js → validateDocument-Dws_67d7.js} +41 -214
- package/lib/validateDocument-Dws_67d7.js.map +1 -0
- package/package.json +5 -5
- package/lib/validateDocument-B0K7YlIj.js.map +0 -1
package/README.md
CHANGED
|
@@ -24,7 +24,6 @@ if (!complete) {
|
|
|
24
24
|
- `status` is deprecated; use `complete` and inspect marker levels and codes. It treats any marker as `failed`.
|
|
25
25
|
- Built-in codes: `validationMarkerCodes`. Custom validators can return namespaced codes such as `custom.seo-title`.
|
|
26
26
|
- Omit `client` for local checks without custom callbacks or network checks. Skipped checks make `complete` false. Use `customValidation: false` to skip custom callbacks while keeping network checks.
|
|
27
|
-
- Pass `i18n: workspace.i18n` to `validateDocument`/`validateDocuments` to preserve the workspace's locale and translation resources, including those used by custom validators through `context.i18n`.
|
|
28
27
|
- Precompiled rules retain their original package version's behavior; recompile with the current version for current callback-skipping and concurrency semantics.
|
|
29
28
|
|
|
30
29
|
## Batch validation
|
|
@@ -38,12 +37,6 @@ const results = await validateDocuments({documents, schema, client, maxFetchConc
|
|
|
38
37
|
|
|
39
38
|
`maxFetchConcurrency` defaults to 25. One `signal` cancels the entire batch.
|
|
40
39
|
|
|
41
|
-
## Reference target types
|
|
42
|
-
|
|
43
|
-
Reference targets are checked against the field's `to` types by default.
|
|
44
|
-
Set `validateReferenceTypes: false` to disable these checks and their network reads.
|
|
45
|
-
If a target's type cannot be checked, validation is marked incomplete.
|
|
46
|
-
|
|
47
40
|
## Cancellation
|
|
48
41
|
|
|
49
42
|
```ts
|
package/lib/_internal.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { E as LocaleSource, S as ValidationMarkerCode, T as ValidationScheduling, d as evaluateDocumentInternal, f as evaluateDocumentObservable, g as validateDocumentObservable, h as validateDocumentInternal, n as ValidateDocumentInternalOptions, p as resolveTypeForArrayItem, r as ValidateDocumentObservableOptions, s as ValidateItemOptions, w as ValidationContext, y as validateItem } from "./validateDocument-
|
|
1
|
+
import { E as LocaleSource, S as ValidationMarkerCode, T as ValidationScheduling, d as evaluateDocumentInternal, f as evaluateDocumentObservable, g as validateDocumentObservable, h as validateDocumentInternal, n as ValidateDocumentInternalOptions, p as resolveTypeForArrayItem, r as ValidateDocumentObservableOptions, s as ValidateItemOptions, w as ValidationContext, y as validateItem } from "./validateDocument-Bqq2KtlY.js";
|
|
2
2
|
import { Path, Rule as Rule$1, RuleClass, Schema, SchemaType, SchemaValidationValue, ValidationContext as ValidationContext$1, ValidationError, ValidationMarker } from "@sanity/types";
|
|
3
|
-
import { accepts } from "@sanity/util/accepts";
|
|
4
3
|
export declare function getFallbackLocaleSource(): LocaleSource;
|
|
5
4
|
export declare const validationLocaleStrings: {
|
|
6
5
|
readonly 'array.exact-length': 'Must have exactly {{wantedLength}} items';
|
|
@@ -23,9 +22,6 @@ export declare const validationLocaleStrings: {
|
|
|
23
22
|
readonly 'number.maximum-precision': 'Max precision is {{limit}}';
|
|
24
23
|
readonly 'number.minimum': 'Must be greater than or equal to {{minNumber}}';
|
|
25
24
|
readonly 'number.non-integer': 'Must be an integer';
|
|
26
|
-
readonly 'object.asset-not-accepted': 'File type "{{mimeType}}" is not accepted';
|
|
27
|
-
readonly 'object.asset-not-accepted_file': 'File type "{{mimeType}}" is not accepted';
|
|
28
|
-
readonly 'object.asset-not-accepted_image': 'Image type "{{mimeType}}" is not accepted';
|
|
29
25
|
readonly 'object.asset-required': 'Asset is required';
|
|
30
26
|
readonly 'object.asset-required_file': 'File is required';
|
|
31
27
|
readonly 'object.asset-required_image': 'Image is required';
|
|
@@ -33,7 +29,6 @@ export declare const validationLocaleStrings: {
|
|
|
33
29
|
readonly 'object.not-media-library-asset': 'Must be a reference to a Media Library asset';
|
|
34
30
|
readonly 'object.not-reference': 'Must be a reference to a document';
|
|
35
31
|
readonly 'object.reference-not-published': 'Referenced document must be published';
|
|
36
|
-
readonly 'object.reference-target-type-mismatch': 'Referenced document has type "{{actualType}}"; expected one of: {{allowedTypes}}';
|
|
37
32
|
readonly 'slug.missing-current': 'Slug must have a value';
|
|
38
33
|
readonly 'slug.not-object': 'Slug must be an object';
|
|
39
34
|
readonly 'slug.not-unique': 'Slug is already in use';
|
|
@@ -97,5 +92,5 @@ export declare function getTypeChain(type: SchemaType | undefined, visited?: Set
|
|
|
97
92
|
export declare function normalizeValidationRules(typeDef: SchemaType | undefined, context?: ValidationContext$1): Rule$1[];
|
|
98
93
|
export declare function pathToString(path?: Path | undefined): string;
|
|
99
94
|
export declare function typeString(obj: unknown): string;
|
|
100
|
-
export { type LocaleSource, type ValidateDocumentInternalOptions, type ValidateDocumentObservableOptions, type ValidateItemOptions, type ValidationContext, type ValidationScheduling,
|
|
95
|
+
export { type LocaleSource, type ValidateDocumentInternalOptions, type ValidateDocumentObservableOptions, type ValidateItemOptions, type ValidationContext, type ValidationScheduling, evaluateDocumentInternal, evaluateDocumentObservable, resolveTypeForArrayItem, validateDocumentInternal, validateDocumentObservable, validateItem };
|
|
101
96
|
//# sourceMappingURL=_internal.d.ts.map
|
package/lib/_internal.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { _ as pathToString, a as validateDocumentInternal, d as compileValidationRules, f as normalizeValidationRules, g as convertToValidationMarker, h as typeString, l as validateItem, m as getTypeChain, n as evaluateDocumentObservable, o as validateDocumentObservable, p as Rule, r as resolveTypeForArrayItem, t as evaluateDocumentInternal, v as getFallbackLocaleSource, y as validationLocaleStrings } from "./validateDocument-
|
|
2
|
-
import { accepts } from "@sanity/util/accepts";
|
|
1
|
+
import { _ as pathToString, a as validateDocumentInternal, d as compileValidationRules, f as normalizeValidationRules, g as convertToValidationMarker, h as typeString, l as validateItem, m as getTypeChain, n as evaluateDocumentObservable, o as validateDocumentObservable, p as Rule, r as resolveTypeForArrayItem, t as evaluateDocumentInternal, v as getFallbackLocaleSource, y as validationLocaleStrings } from "./validateDocument-Dws_67d7.js";
|
|
3
2
|
function inferFromSchemaType(typeDef) {
|
|
4
3
|
return traverse(typeDef, /* @__PURE__ */ new Set()), typeDef;
|
|
5
4
|
}
|
|
@@ -35,6 +34,6 @@ function inferFromSchema(schema) {
|
|
|
35
34
|
schemaType && inferFromSchemaType(schemaType);
|
|
36
35
|
}), schema;
|
|
37
36
|
}
|
|
38
|
-
export { Rule,
|
|
37
|
+
export { Rule, convertToValidationMarker, evaluateDocumentInternal, evaluateDocumentObservable, getFallbackLocaleSource, getTypeChain, hasValidationContext, inferFromSchema, inferFromSchemaType, normalizeValidationRules, pathToString, resolveTypeForArrayItem, typeString, validateDocumentInternal, validateDocumentObservable, validateItem, validationLocaleStrings };
|
|
39
38
|
|
|
40
39
|
//# sourceMappingURL=_internal.js.map
|
package/lib/_internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_internal.js","names":[],"sources":["../src/inferFromSchemaType.ts","../src/inferFromSchema.ts"],"sourcesContent":["import {type Schema, type SchemaType, type SchemaValidationValue} from '@sanity/types'\n\nimport {compileValidationRules} from './util/normalizeValidationRules'\n\n// NOTE: this overload is for TS API compatibility with a previous implementation\nexport function inferFromSchemaType(\n typeDef: SchemaType,\n // these are intentionally unused\n _schema: Schema,\n _visited?: Set<SchemaType>,\n): SchemaType\n// note: this seemingly redundant overload is required\nexport function inferFromSchemaType(typeDef: SchemaType): SchemaType\nexport function inferFromSchemaType(typeDef: SchemaType): SchemaType {\n traverse(typeDef, new Set())\n return typeDef\n}\n\nfunction traverse(typeDef: SchemaType, visited: Set<SchemaType>) {\n if (visited.has(typeDef)) {\n return\n }\n\n visited.add(typeDef)\n\n const usesValidationContext = hasValidationContext(typeDef.validation)\n\n // Only normalize validation at schema-compile time when it doesn't rely on runtime context.\n // Context-aware validation functions must be evaluated during validation, where context exists.\n if (!usesValidationContext) {\n typeDef.validation = compileValidationRules(typeDef)\n }\n\n if ('fields' in typeDef) {\n for (const field of typeDef.fields) {\n traverse(field.type, visited)\n }\n }\n\n if ('of' in typeDef) {\n for (const candidate of typeDef.of) {\n traverse(candidate, visited)\n }\n }\n\n // @ts-expect-error TODO (eventually): `annotations` does not exist on the SchemaType yet\n if (typeDef.annotations) {\n // @ts-expect-error TODO (eventually): `annotations` does not exist on the SchemaType yet\n for (const annotation of typeDef.annotations) {\n traverse(annotation, visited)\n }\n }\n}\n\n/**\n * Checks if a validation function may use the context parameter.\n *\n * Functions with 2+ parameters like `(rule, context) => ...` need runtime context\n * (e.g., `context.hidden`, `context.document`) and cannot be pre-evaluated at schema compile time.\n *\n * Simple functions with only a rule parameter can be normalized immediately.\n * Unrecognized signatures are deferred because their arity may hide context usage.\n *\n * @internal\n */\nexport function hasValidationContext(validation: SchemaValidationValue | undefined): boolean {\n if (!validation) return false\n if (Array.isArray(validation)) {\n return validation.some(hasValidationContext)\n }\n if (typeof validation !== 'function') return false\n\n // Check declared parameter count first (most common case)\n if (validation.length >= 2) return true\n\n // Default and rest parameters do not contribute to Function.length. Only compile\n // recognizable zero/one-parameter signatures; wrappers and unknown forms stay at runtime.\n const signature = Function.prototype.toString.call(validation)\n if (/\\barguments\\b|\\[native code\\]/.test(signature)) return true\n\n const simpleArrow = /^\\s*(?:[\\w$]+|\\(\\s*(?:[\\w$]+\\s*)?\\))\\s*=>/\n const simpleFunction = /^\\s*(?:function(?:\\s+[\\w$]+)?|[\\w$]+)\\s*\\(\\s*(?:[\\w$]+\\s*)?\\)\\s*\\{/\n return !simpleArrow.test(signature) && !simpleFunction.test(signature)\n}\n","import {type Schema} from '@sanity/types'\n\nimport {inferFromSchemaType} from './inferFromSchemaType'\n\n// Note: Mutates schema. Refactor when @sanity/schema supports middlewares\nexport function inferFromSchema(schema: Schema): Schema {\n const typeNames = schema.getLocalTypeNames()\n\n typeNames.forEach((typeName) => {\n const schemaType = schema.get(typeName)\n\n if (schemaType) {\n inferFromSchemaType(schemaType)\n }\n })\n\n return schema\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"_internal.js","names":[],"sources":["../src/inferFromSchemaType.ts","../src/inferFromSchema.ts"],"sourcesContent":["import {type Schema, type SchemaType, type SchemaValidationValue} from '@sanity/types'\n\nimport {compileValidationRules} from './util/normalizeValidationRules'\n\n// NOTE: this overload is for TS API compatibility with a previous implementation\nexport function inferFromSchemaType(\n typeDef: SchemaType,\n // these are intentionally unused\n _schema: Schema,\n _visited?: Set<SchemaType>,\n): SchemaType\n// note: this seemingly redundant overload is required\nexport function inferFromSchemaType(typeDef: SchemaType): SchemaType\nexport function inferFromSchemaType(typeDef: SchemaType): SchemaType {\n traverse(typeDef, new Set())\n return typeDef\n}\n\nfunction traverse(typeDef: SchemaType, visited: Set<SchemaType>) {\n if (visited.has(typeDef)) {\n return\n }\n\n visited.add(typeDef)\n\n const usesValidationContext = hasValidationContext(typeDef.validation)\n\n // Only normalize validation at schema-compile time when it doesn't rely on runtime context.\n // Context-aware validation functions must be evaluated during validation, where context exists.\n if (!usesValidationContext) {\n typeDef.validation = compileValidationRules(typeDef)\n }\n\n if ('fields' in typeDef) {\n for (const field of typeDef.fields) {\n traverse(field.type, visited)\n }\n }\n\n if ('of' in typeDef) {\n for (const candidate of typeDef.of) {\n traverse(candidate, visited)\n }\n }\n\n // @ts-expect-error TODO (eventually): `annotations` does not exist on the SchemaType yet\n if (typeDef.annotations) {\n // @ts-expect-error TODO (eventually): `annotations` does not exist on the SchemaType yet\n for (const annotation of typeDef.annotations) {\n traverse(annotation, visited)\n }\n }\n}\n\n/**\n * Checks if a validation function may use the context parameter.\n *\n * Functions with 2+ parameters like `(rule, context) => ...` need runtime context\n * (e.g., `context.hidden`, `context.document`) and cannot be pre-evaluated at schema compile time.\n *\n * Simple functions with only a rule parameter can be normalized immediately.\n * Unrecognized signatures are deferred because their arity may hide context usage.\n *\n * @internal\n */\nexport function hasValidationContext(validation: SchemaValidationValue | undefined): boolean {\n if (!validation) return false\n if (Array.isArray(validation)) {\n return validation.some(hasValidationContext)\n }\n if (typeof validation !== 'function') return false\n\n // Check declared parameter count first (most common case)\n if (validation.length >= 2) return true\n\n // Default and rest parameters do not contribute to Function.length. Only compile\n // recognizable zero/one-parameter signatures; wrappers and unknown forms stay at runtime.\n const signature = Function.prototype.toString.call(validation)\n if (/\\barguments\\b|\\[native code\\]/.test(signature)) return true\n\n const simpleArrow = /^\\s*(?:[\\w$]+|\\(\\s*(?:[\\w$]+\\s*)?\\))\\s*=>/\n const simpleFunction = /^\\s*(?:function(?:\\s+[\\w$]+)?|[\\w$]+)\\s*\\(\\s*(?:[\\w$]+\\s*)?\\)\\s*\\{/\n return !simpleArrow.test(signature) && !simpleFunction.test(signature)\n}\n","import {type Schema} from '@sanity/types'\n\nimport {inferFromSchemaType} from './inferFromSchemaType'\n\n// Note: Mutates schema. Refactor when @sanity/schema supports middlewares\nexport function inferFromSchema(schema: Schema): Schema {\n const typeNames = schema.getLocalTypeNames()\n\n typeNames.forEach((typeName) => {\n const schemaType = schema.get(typeName)\n\n if (schemaType) {\n inferFromSchemaType(schemaType)\n }\n })\n\n return schema\n}\n"],"mappings":";AAaA,SAAgB,oBAAoB,SAAiC;CAEnE,OADA,SAAS,yBAAS,IAAI,IAAI,CAAC,GACpB;AACT;AAEA,SAAS,SAAS,SAAqB,SAA0B;CAC/D,IAAI,SAAQ,IAAI,OAAO,GAIvB;EAUA,IAVA,QAAQ,IAAI,OAAO,GAEW,qBAAqB,QAAQ,UAIlC,MACvB,QAAQ,aAAa,uBAAuB,OAAO,IAGjD,YAAY,SACd,KAAK,IAAM,SAAS,QAAQ,QAC1B,SAAS,MAAM,MAAM,OAAO;EAIhC,IAAI,QAAQ,SACV,KAAK,IAAM,aAAa,QAAQ,IAC9B,SAAS,WAAW,OAAO;EAK/B,IAAI,QAAQ,aAEV,KAAK,IAAM,cAAc,QAAQ,aAC/B,SAAS,YAAY,OAAO;CA1Bb;AA6BrB;;;;;;;;;;;;AAaA,SAAgB,qBAAqB,YAAwD;CAC3F,IAAI,CAAC,YAAY,OAAO;CACxB,IAAI,MAAM,QAAQ,UAAU,GAC1B,OAAO,WAAW,KAAK,oBAAoB;CAE7C,IAAI,OAAO,cAAe,YAAY,OAAO;CAG7C,IAAI,WAAW,UAAU,GAAG,OAAO;CAInC,IAAM,YAAY,SAAS,UAAU,SAAS,KAAK,UAAU;CAK7D,OAJI,gCAAgC,KAAK,SAAS,IAAU,KAIrD,CAAC,4CAAY,KAAK,SAAS,KAAK,CAAC,qEAAe,KAAK,SAAS;AACvE;AC9EA,SAAgB,gBAAgB,QAAwB;CAWtD,OARA,OAFyB,kBAEjB,CAAC,CAAC,SAAS,aAAa;EAC9B,IAAM,aAAa,OAAO,IAAI,QAAQ;EAEtC,AAAI,cACF,oBAAoB,UAAU;CAElC,CAAC,GAEM;AACT"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as validationMarkerCodes,
|
|
1
|
+
import { C as validationMarkerCodes, S as ValidationMarkerCode, _ as validateDocumentWithWorkspace, a as ValidateDocumentWorkspaceOptions, b as BuiltInValidationMarkerCode, c as ValidationClient, i as ValidateDocumentOptions, l as ValidationSchema, m as validateDocument, o as ValidateDocumentsOptions, t as DocumentValidationResult, u as ValidationSource, v as validateDocuments, x as DocumentValidationMarker } from "./validateDocument-Bqq2KtlY.js";
|
|
2
2
|
import { SanityDocument } from "@sanity/types";
|
|
3
3
|
type DocumentCheck = (options: {
|
|
4
4
|
id: string;
|
|
@@ -21,5 +21,5 @@ interface ReleaseReferenceOptions {
|
|
|
21
21
|
* @beta
|
|
22
22
|
*/
|
|
23
23
|
export declare function withReleaseReferences({ document, getDocumentExists, isUnpublished }: ReleaseReferenceOptions): DocumentCheck;
|
|
24
|
-
export { type BuiltInValidationMarkerCode, type DocumentValidationMarker, type DocumentValidationResult, type ReleaseReferenceOptions, type ValidateDocumentOptions, type ValidateDocumentWorkspaceOptions, type ValidateDocumentsOptions, type ValidationClient, type
|
|
24
|
+
export { type BuiltInValidationMarkerCode, type DocumentValidationMarker, type DocumentValidationResult, type ReleaseReferenceOptions, type ValidateDocumentOptions, type ValidateDocumentWorkspaceOptions, type ValidateDocumentsOptions, type ValidationClient, type ValidationMarkerCode, type ValidationSchema, type ValidationSource, validateDocument, validateDocumentWithWorkspace, validateDocuments, validationMarkerCodes };
|
|
25
25
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { i as validateDocument, s as validateDocumentWithWorkspace, c as validateDocuments, b as validationMarkerCodes, u as withReleaseReferences } from "./validateDocument-
|
|
1
|
+
export { i as validateDocument, s as validateDocumentWithWorkspace, c as validateDocuments, b as validationMarkerCodes, u as withReleaseReferences } from "./validateDocument-Dws_67d7.js";
|
|
@@ -3,22 +3,11 @@ import { ConcurrencyLimiter } from "@sanity/util/concurrency-limiter";
|
|
|
3
3
|
import { BehaviorSubject, Observable } from "rxjs";
|
|
4
4
|
import { TFunction } from "i18next";
|
|
5
5
|
import { SanityClient } from "@sanity/client";
|
|
6
|
-
|
|
7
|
-
* Translation utilities accepted across compatible Studio and i18next versions.
|
|
8
|
-
*
|
|
9
|
-
* @beta
|
|
10
|
-
*/
|
|
11
|
-
interface ValidationLocaleSource {
|
|
12
|
-
/** The locale used for localized validation messages. */
|
|
6
|
+
interface LocaleSource {
|
|
13
7
|
currentLocale: {
|
|
14
8
|
id: string;
|
|
15
9
|
};
|
|
16
|
-
/** Loads translation resources needed by built-in or custom validators. */
|
|
17
10
|
loadNamespaces(namespaces: string[]): Promise<void>;
|
|
18
|
-
/** Translates a key with optional interpolation and formatting options. */
|
|
19
|
-
t: (key: string, options?: Record<string, unknown>) => string;
|
|
20
|
-
}
|
|
21
|
-
interface LocaleSource extends ValidationLocaleSource {
|
|
22
11
|
t: TFunction;
|
|
23
12
|
}
|
|
24
13
|
/**
|
|
@@ -67,7 +56,6 @@ declare module '@sanity/types' {
|
|
|
67
56
|
}
|
|
68
57
|
interface InternalValidationContext extends ValidationContext {
|
|
69
58
|
__internal?: {
|
|
70
|
-
getDocumentType?: (id: string) => Promise<string | undefined>;
|
|
71
59
|
customValidation?: boolean;
|
|
72
60
|
customValidationConcurrencyLimiter?: {
|
|
73
61
|
ready: (signal?: AbortSignal) => Promise<void>;
|
|
@@ -85,7 +73,6 @@ declare const validationMarkerCodes: {
|
|
|
85
73
|
readonly arrayExactLength: 'array.exact-length';
|
|
86
74
|
readonly arrayMaximumLength: 'array.maximum-length';
|
|
87
75
|
readonly arrayMinimumLength: 'array.minimum-length';
|
|
88
|
-
readonly assetNotAccepted: 'asset.not-accepted';
|
|
89
76
|
readonly assetRequired: 'asset.required';
|
|
90
77
|
readonly custom: 'custom';
|
|
91
78
|
readonly dateInvalidFormat: 'date.invalid-format';
|
|
@@ -104,7 +91,6 @@ declare const validationMarkerCodes: {
|
|
|
104
91
|
readonly objectUnknownField: 'object.unknown-field';
|
|
105
92
|
readonly referenceInvalid: 'reference.invalid';
|
|
106
93
|
readonly referenceNotPublished: 'reference.not-published';
|
|
107
|
-
readonly referenceTargetTypeMismatch: 'reference.target-type-mismatch';
|
|
108
94
|
readonly ruleAllFailed: 'rule.all-failed';
|
|
109
95
|
readonly ruleEitherFailed: 'rule.either-failed';
|
|
110
96
|
readonly slugInvalidType: 'slug.invalid-type';
|
|
@@ -152,12 +138,6 @@ interface ValidateDocumentBaseOptions {
|
|
|
152
138
|
document: SanityDocument;
|
|
153
139
|
/** The compiled schema to validate against. */
|
|
154
140
|
schema: ValidationSchema;
|
|
155
|
-
/**
|
|
156
|
-
* Translation resources and locale used by built-in and custom validators.
|
|
157
|
-
* Pass a resolved workspace's `i18n` to preserve its translations.
|
|
158
|
-
* Defaults to the built-in English resources when omitted.
|
|
159
|
-
*/
|
|
160
|
-
i18n?: ValidationLocaleSource;
|
|
161
141
|
/** Signal used to cancel validation and any work it starts. */
|
|
162
142
|
signal?: AbortSignal;
|
|
163
143
|
/**
|
|
@@ -173,14 +153,6 @@ interface ValidateDocumentBaseOptions {
|
|
|
173
153
|
id: string;
|
|
174
154
|
signal?: AbortSignal;
|
|
175
155
|
}) => Promise<boolean>;
|
|
176
|
-
/**
|
|
177
|
-
* Check referenced document types against the reference field's `to` types.
|
|
178
|
-
* Defaults to `true` (`false` in Studio's `validateDocument`).
|
|
179
|
-
* Uses batched network reads, including for weak references.
|
|
180
|
-
* Without a client, checks that need a target lookup make validation incomplete.
|
|
181
|
-
* Set to `false` to perform only the existing reference shape and existence checks.
|
|
182
|
-
*/
|
|
183
|
-
validateReferenceTypes?: boolean;
|
|
184
156
|
/**
|
|
185
157
|
* The maximum amount of custom validation functions to be running
|
|
186
158
|
* concurrently at once. This helps prevent custom validators from
|
|
@@ -290,7 +262,7 @@ interface ValidationSource {
|
|
|
290
262
|
*
|
|
291
263
|
* @beta
|
|
292
264
|
*/
|
|
293
|
-
interface ValidateDocumentWorkspaceOptions extends Omit<ValidateDocumentBaseOptions, 'schema'
|
|
265
|
+
interface ValidateDocumentWorkspaceOptions extends Omit<ValidateDocumentBaseOptions, 'schema'> {
|
|
294
266
|
/** The resolved Studio workspace or source used for validation. */
|
|
295
267
|
workspace: ValidationSource;
|
|
296
268
|
/**
|
|
@@ -310,7 +282,7 @@ interface ValidateDocumentWorkspaceOptions extends Omit<ValidateDocumentBaseOpti
|
|
|
310
282
|
* @beta
|
|
311
283
|
* @deprecated Prefer {@link validateDocument} with `{document, schema, client}` for new code.
|
|
312
284
|
*/
|
|
313
|
-
declare function validateDocumentWithWorkspace({ document, workspace, getClient, getDocumentExists, environment, maxCustomValidationConcurrency, maxFetchConcurrency, currentUser, customValidation, signal
|
|
285
|
+
declare function validateDocumentWithWorkspace({ document, workspace, getClient, getDocumentExists, environment, maxCustomValidationConcurrency, maxFetchConcurrency, currentUser, customValidation, signal }: ValidateDocumentWorkspaceOptions): Promise<DocumentValidationMarker[]>;
|
|
314
286
|
/**
|
|
315
287
|
* Validates a document against a compiled schema. Returns failures and whether
|
|
316
288
|
* validation completed
|
|
@@ -338,7 +310,6 @@ interface ValidateDocumentInternalOptions {
|
|
|
338
310
|
id: string;
|
|
339
311
|
signal?: AbortSignal;
|
|
340
312
|
}) => Promise<boolean>;
|
|
341
|
-
validateReferenceTypes?: boolean;
|
|
342
313
|
i18n?: LocaleSource;
|
|
343
314
|
environment: 'cli' | 'studio';
|
|
344
315
|
maxCustomValidationConcurrency?: number;
|
|
@@ -355,8 +326,6 @@ declare function evaluateDocumentInternal(options: ValidateDocumentInternalOptio
|
|
|
355
326
|
* @internal
|
|
356
327
|
*/
|
|
357
328
|
interface ValidateDocumentObservableOptions extends Pick<ValidationContext$1, 'getDocumentExists' | 'i18n' | 'signal' | 'currentUser'> {
|
|
358
|
-
/** Lookup for resolved target types. Omit to disable type checks. */
|
|
359
|
-
getDocumentType?: (id: string) => Promise<string | undefined>;
|
|
360
329
|
getClient: (options: {
|
|
361
330
|
apiVersion: string;
|
|
362
331
|
}) => SanityClient;
|
|
@@ -400,5 +369,5 @@ type ValidateItemOptions = {
|
|
|
400
369
|
__internal?: InternalValidationContext['__internal'];
|
|
401
370
|
} & Pick<ValidationContext$1, 'currentUser'> & ExplicitUndefined<Omit<ValidationContext$1, 'hidden' | 'signal' | 'currentUser'>>;
|
|
402
371
|
declare function validateItem(opts: ValidateItemOptions): Promise<ValidationMarker[]>;
|
|
403
|
-
export { validationMarkerCodes as C,
|
|
404
|
-
//# sourceMappingURL=validateDocument-
|
|
372
|
+
export { validationMarkerCodes as C, LocaleSource as E, ValidationMarkerCode as S, ValidationScheduling as T, validateDocumentWithWorkspace as _, ValidateDocumentWorkspaceOptions as a, BuiltInValidationMarkerCode as b, ValidationClient as c, evaluateDocumentInternal as d, evaluateDocumentObservable as f, validateDocumentObservable as g, validateDocumentInternal as h, ValidateDocumentOptions as i, ValidationSchema as l, validateDocument as m, ValidateDocumentInternalOptions as n, ValidateDocumentsOptions as o, resolveTypeForArrayItem as p, ValidateDocumentObservableOptions as r, ValidateItemOptions as s, DocumentValidationResult as t, ValidationSource as u, validateDocuments as v, ValidationContext$1 as w, DocumentValidationMarker as x, validateItem as y };
|
|
373
|
+
//# sourceMappingURL=validateDocument-Bqq2KtlY.d.ts.map
|