sanity-advanced-validators 0.0.1

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.
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/requiredIfPeerEq.ts
21
+ var requiredIfPeerEq_exports = {};
22
+ __export(requiredIfPeerEq_exports, {
23
+ requiredIfPeerEq: () => requiredIfPeerEq
24
+ });
25
+ module.exports = __toCommonJS(requiredIfPeerEq_exports);
26
+
27
+ // src/fileExtension.ts
28
+ var import_asset_utils = require("@sanity/asset-utils");
29
+
30
+ // src/minDimensions.ts
31
+ var import_asset_utils2 = require("@sanity/asset-utils");
32
+
33
+ // src/lib/getPeer.ts
34
+ var import_lodash_es = require("lodash-es");
35
+ var getPeer = (key, context) => {
36
+ const pathToParentObject = context.path.slice(0, -1);
37
+ const peer = (0, import_lodash_es.get)(context.document, [...pathToParentObject, key]);
38
+ return peer;
39
+ };
40
+
41
+ // src/requiredIfPeerEq.ts
42
+ var requiredIfPeerEq = (key, comparison, message = "Required if {key} equals {value}.") => (value, context) => {
43
+ var _a;
44
+ const peer = getPeer(key, context);
45
+ const comparisons = Array.isArray(comparison) ? comparison : [comparison];
46
+ if (!value && comparisons.includes(peer)) {
47
+ return message.replace("{key}", key).replace("{value}", (_a = comparisons.join(", or ")) != null ? _a : "null");
48
+ }
49
+ return true;
50
+ };
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ requiredIfPeerEq
54
+ });