@valbuild/core 0.72.0 → 0.72.2
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/dist/declarations/src/schema/richtext.d.ts +1 -0
- package/dist/declarations/src/schema/validation/ValidationFix.d.ts +1 -1
- package/dist/{index-6d63e99d.cjs.prod.js → index-380b80a1.cjs.prod.js} +191 -4
- package/dist/{index-1d65adb5.esm.js → index-7218e8b1.esm.js} +191 -4
- package/dist/{index-47055fcc.cjs.dev.js → index-7ae61742.cjs.dev.js} +191 -4
- package/dist/valbuild-core.cjs.dev.js +1 -1
- package/dist/valbuild-core.cjs.prod.js +1 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/expr/dist/valbuild-core-expr.cjs.dev.js +1 -1
- package/expr/dist/valbuild-core-expr.cjs.prod.js +1 -1
- package/expr/dist/valbuild-core-expr.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
@@ -12,6 +12,7 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
|
|
12
12
|
readonly opt: boolean;
|
13
13
|
constructor(options: O, opt?: boolean);
|
14
14
|
validate(path: SourcePath, src: Src): ValidationErrors;
|
15
|
+
private recursiveValidate;
|
15
16
|
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
16
17
|
private recursiveAssert;
|
17
18
|
nullable(): Schema<Src | null>;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const ValidationFix: readonly ["image:change-extension", "image:add-metadata", "image:check-metadata", "file:change-extension", "file:add-metadata", "file:check-metadata"];
|
1
|
+
export declare const ValidationFix: readonly ["image:change-extension", "image:add-metadata", "image:check-metadata", "file:change-extension", "file:add-metadata", "file:check-metadata", "keyof:check-keys"];
|
2
2
|
export type ValidationFix = (typeof ValidationFix)[number];
|
@@ -2107,7 +2107,170 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2107
2107
|
if (!assertRes.success) {
|
2108
2108
|
return _defineProperty({}, path, assertRes.errors[path]);
|
2109
2109
|
}
|
2110
|
-
|
2110
|
+
var nodes = assertRes.data;
|
2111
|
+
if (nodes === null && this.opt) {
|
2112
|
+
return false;
|
2113
|
+
}
|
2114
|
+
if (nodes === null) {
|
2115
|
+
return _defineProperty({}, path, [{
|
2116
|
+
message: "Expected 'array', got 'null'",
|
2117
|
+
typeError: true
|
2118
|
+
}]);
|
2119
|
+
}
|
2120
|
+
var current = {};
|
2121
|
+
var typeErrorRes = this.recursiveValidate(path, nodes, current);
|
2122
|
+
if (typeErrorRes) {
|
2123
|
+
return typeErrorRes;
|
2124
|
+
}
|
2125
|
+
if (Object.keys(current).length > 0) {
|
2126
|
+
return current;
|
2127
|
+
}
|
2128
|
+
return false;
|
2129
|
+
}
|
2130
|
+
}, {
|
2131
|
+
key: "recursiveValidate",
|
2132
|
+
value: function recursiveValidate(rootPath, nodes, current) {
|
2133
|
+
var addError = function addError(path, message, typeError) {
|
2134
|
+
if (!current[path]) {
|
2135
|
+
current[path] = [];
|
2136
|
+
}
|
2137
|
+
current[path].push({
|
2138
|
+
message: message,
|
2139
|
+
typeError: typeError
|
2140
|
+
});
|
2141
|
+
};
|
2142
|
+
var _iterator = result._createForOfIteratorHelper(nodes),
|
2143
|
+
_step;
|
2144
|
+
try {
|
2145
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
2146
|
+
var _this$options$block, _this$options$block2, _this$options$block3, _this$options$block4, _this$options$block5, _this$options$block6, _this$options$block7, _this$options$block8, _this$options$block9, _this$options$block10, _this$options$inline, _this$options$inline2;
|
2147
|
+
var node = _step.value;
|
2148
|
+
var path = unsafeCreateSourcePath(rootPath, nodes.indexOf(node));
|
2149
|
+
if (typeof node === "string") {
|
2150
|
+
continue;
|
2151
|
+
}
|
2152
|
+
if (_typeof(node) !== "object") {
|
2153
|
+
return _defineProperty({}, path, [{
|
2154
|
+
message: "Expected nodes of type 'object' or 'string', got '".concat(_typeof(node), "'"),
|
2155
|
+
typeError: true
|
2156
|
+
}]);
|
2157
|
+
}
|
2158
|
+
if (node === null) {
|
2159
|
+
return _defineProperty({}, path, [{
|
2160
|
+
message: "Expected nodes of type 'object' or 'string', got 'null'",
|
2161
|
+
typeError: true
|
2162
|
+
}]);
|
2163
|
+
}
|
2164
|
+
if (!("tag" in node)) {
|
2165
|
+
return _defineProperty({}, path, [{
|
2166
|
+
message: "Expected node to either have 'tag' or be of type 'string'",
|
2167
|
+
typeError: true
|
2168
|
+
}]);
|
2169
|
+
}
|
2170
|
+
if (typeof node.tag !== "string") {
|
2171
|
+
return _defineProperty({}, path, [{
|
2172
|
+
message: "Expected 'string', got '".concat(_typeof(node.tag), "'"),
|
2173
|
+
typeError: true
|
2174
|
+
}]);
|
2175
|
+
}
|
2176
|
+
if (node.tag === "h1" && !((_this$options$block = this.options.block) !== null && _this$options$block !== void 0 && _this$options$block.h1)) {
|
2177
|
+
addError(path, "'h' block is not valid", false);
|
2178
|
+
}
|
2179
|
+
if (node.tag === "h2" && !((_this$options$block2 = this.options.block) !== null && _this$options$block2 !== void 0 && _this$options$block2.h2)) {
|
2180
|
+
addError(path, "'h2' block is not valid", false);
|
2181
|
+
}
|
2182
|
+
if (node.tag === "h3" && !((_this$options$block3 = this.options.block) !== null && _this$options$block3 !== void 0 && _this$options$block3.h3)) {
|
2183
|
+
addError(path, "'h3' block is not valid", false);
|
2184
|
+
}
|
2185
|
+
if (node.tag === "h4" && !((_this$options$block4 = this.options.block) !== null && _this$options$block4 !== void 0 && _this$options$block4.h4)) {
|
2186
|
+
addError(path, "'h4' block is not valid", false);
|
2187
|
+
}
|
2188
|
+
if (node.tag === "h5" && !((_this$options$block5 = this.options.block) !== null && _this$options$block5 !== void 0 && _this$options$block5.h5)) {
|
2189
|
+
addError(path, "'h5' block is not valid", false);
|
2190
|
+
}
|
2191
|
+
if (node.tag === "h6" && !((_this$options$block6 = this.options.block) !== null && _this$options$block6 !== void 0 && _this$options$block6.h6)) {
|
2192
|
+
addError(path, "'h6' block is not valid", false);
|
2193
|
+
}
|
2194
|
+
if (node.tag === "ol" && !((_this$options$block7 = this.options.block) !== null && _this$options$block7 !== void 0 && _this$options$block7.ol)) {
|
2195
|
+
addError(path, "'ol' block is not valid", false);
|
2196
|
+
}
|
2197
|
+
if (node.tag === "ul" && !((_this$options$block8 = this.options.block) !== null && _this$options$block8 !== void 0 && _this$options$block8.ul)) {
|
2198
|
+
addError(path, "'ul' block is not valid", false);
|
2199
|
+
}
|
2200
|
+
if (node.tag === "li" && !((_this$options$block9 = this.options.block) !== null && _this$options$block9 !== void 0 && _this$options$block9.ul) && !((_this$options$block10 = this.options.block) !== null && _this$options$block10 !== void 0 && _this$options$block10.ol)) {
|
2201
|
+
addError(path, "'li' tag is invalid since neither 'ul' nor 'ol' block is not valid", false);
|
2202
|
+
}
|
2203
|
+
if (node.tag === "a" && !((_this$options$inline = this.options.inline) !== null && _this$options$inline !== void 0 && _this$options$inline.a)) {
|
2204
|
+
addError(path, "'a' inline is not valid", false);
|
2205
|
+
}
|
2206
|
+
if (node.tag === "img" && !((_this$options$inline2 = this.options.inline) !== null && _this$options$inline2 !== void 0 && _this$options$inline2.img)) {
|
2207
|
+
addError(path, "'img' inline is not valid", false);
|
2208
|
+
}
|
2209
|
+
if ("styles" in node && node.tag !== "span") {
|
2210
|
+
return _defineProperty({}, path, [{
|
2211
|
+
message: "Cannot have styles on '".concat(node.tag, "'. This is only allowed on 'span'"),
|
2212
|
+
typeError: true
|
2213
|
+
}]);
|
2214
|
+
}
|
2215
|
+
if ("styles" in node) {
|
2216
|
+
if (!Array.isArray(node.styles)) {
|
2217
|
+
return _defineProperty({}, path, [{
|
2218
|
+
message: "Expected 'array', got '".concat(_typeof(node.styles), "'"),
|
2219
|
+
typeError: true
|
2220
|
+
}]);
|
2221
|
+
}
|
2222
|
+
var stylesPath = unsafeCreateSourcePath(path, "styles");
|
2223
|
+
for (var i = 0; i < node.styles.length; i++) {
|
2224
|
+
var _this$options$style, _this$options$style2, _this$options$style3;
|
2225
|
+
var style = node.styles[i];
|
2226
|
+
var currentStylePath = unsafeCreateSourcePath(stylesPath, i);
|
2227
|
+
if (typeof style !== "string") {
|
2228
|
+
return _defineProperty({}, currentStylePath, [{
|
2229
|
+
message: "Expected 'string', got '".concat(_typeof(style), "'"),
|
2230
|
+
typeError: true
|
2231
|
+
}]);
|
2232
|
+
}
|
2233
|
+
if (style === "bold" && !((_this$options$style = this.options.style) !== null && _this$options$style !== void 0 && _this$options$style.bold)) {
|
2234
|
+
addError(currentStylePath, "Style 'bold' is not valid", false);
|
2235
|
+
}
|
2236
|
+
if (style === "italic" && !((_this$options$style2 = this.options.style) !== null && _this$options$style2 !== void 0 && _this$options$style2.italic)) {
|
2237
|
+
addError(currentStylePath, "Style 'italic' is not valid", false);
|
2238
|
+
}
|
2239
|
+
if (style === "lineThrough" && !((_this$options$style3 = this.options.style) !== null && _this$options$style3 !== void 0 && _this$options$style3.lineThrough)) {
|
2240
|
+
addError(currentStylePath, "Style 'lineThrough' is not valid", false);
|
2241
|
+
}
|
2242
|
+
}
|
2243
|
+
}
|
2244
|
+
if ("children" in node) {
|
2245
|
+
if (!Array.isArray(node.children)) {
|
2246
|
+
return _defineProperty({}, path, [{
|
2247
|
+
message: "Expected 'array', got '".concat(_typeof(node.children), "'"),
|
2248
|
+
typeError: true
|
2249
|
+
}]);
|
2250
|
+
}
|
2251
|
+
var children = node.children;
|
2252
|
+
for (var _i = 0; _i < children.length; _i++) {
|
2253
|
+
var child = children[_i];
|
2254
|
+
if (_typeof(child) === "object") {
|
2255
|
+
var childPath = unsafeCreateSourcePath(path, "children");
|
2256
|
+
var res = this.recursiveValidate(childPath, [child], current);
|
2257
|
+
if (res) {
|
2258
|
+
return res;
|
2259
|
+
}
|
2260
|
+
} else if (typeof child !== "string") {
|
2261
|
+
return _defineProperty({}, path, [{
|
2262
|
+
message: "Expected 'object' or 'string', got '".concat(_typeof(child), "'"),
|
2263
|
+
typeError: true
|
2264
|
+
}]);
|
2265
|
+
}
|
2266
|
+
}
|
2267
|
+
}
|
2268
|
+
}
|
2269
|
+
} catch (err) {
|
2270
|
+
_iterator.e(err);
|
2271
|
+
} finally {
|
2272
|
+
_iterator.f();
|
2273
|
+
}
|
2111
2274
|
return false;
|
2112
2275
|
}
|
2113
2276
|
}, {
|
@@ -2119,6 +2282,15 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2119
2282
|
data: src
|
2120
2283
|
};
|
2121
2284
|
}
|
2285
|
+
if (src === null && !this.opt) {
|
2286
|
+
return {
|
2287
|
+
success: false,
|
2288
|
+
errors: _defineProperty({}, path, [{
|
2289
|
+
message: "Expected 'array', got 'null'",
|
2290
|
+
typeError: true
|
2291
|
+
}])
|
2292
|
+
};
|
2293
|
+
}
|
2122
2294
|
if (!Array.isArray(src)) {
|
2123
2295
|
return {
|
2124
2296
|
success: false,
|
@@ -2229,10 +2401,10 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2229
2401
|
typeError: true
|
2230
2402
|
});
|
2231
2403
|
} else {
|
2232
|
-
for (var
|
2233
|
-
var style = node.styles[
|
2404
|
+
for (var _i2 = 0; _i2 < node.styles.length; _i2++) {
|
2405
|
+
var style = node.styles[_i2];
|
2234
2406
|
if (typeof style !== "string") {
|
2235
|
-
var _pathAtError = unsafeCreateSourcePath(path,
|
2407
|
+
var _pathAtError = unsafeCreateSourcePath(path, _i2);
|
2236
2408
|
if (!errors[_pathAtError]) {
|
2237
2409
|
errors[_pathAtError] = [];
|
2238
2410
|
}
|
@@ -3149,6 +3321,21 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
3149
3321
|
}]);
|
3150
3322
|
}
|
3151
3323
|
}
|
3324
|
+
if (serializedSchema.type === "record") {
|
3325
|
+
if (typeof src !== "string") {
|
3326
|
+
return _defineProperty({}, path, [{
|
3327
|
+
message: "Value of keyOf (record) must be 'string'. Found: ".concat(_typeof(src))
|
3328
|
+
}]);
|
3329
|
+
}
|
3330
|
+
return _defineProperty({}, path, [{
|
3331
|
+
fixes: ["keyof:check-keys"],
|
3332
|
+
message: "Did not validate keyOf (record). This error (keyof:check-keys) should typically be processed by Val internally. Seeing this error most likely means you have a Val version mismatch.",
|
3333
|
+
value: {
|
3334
|
+
key: src,
|
3335
|
+
sourcePath: this.sourcePath
|
3336
|
+
}
|
3337
|
+
}]);
|
3338
|
+
}
|
3152
3339
|
return false;
|
3153
3340
|
}
|
3154
3341
|
}, {
|
@@ -2105,7 +2105,170 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2105
2105
|
if (!assertRes.success) {
|
2106
2106
|
return _defineProperty({}, path, assertRes.errors[path]);
|
2107
2107
|
}
|
2108
|
-
|
2108
|
+
var nodes = assertRes.data;
|
2109
|
+
if (nodes === null && this.opt) {
|
2110
|
+
return false;
|
2111
|
+
}
|
2112
|
+
if (nodes === null) {
|
2113
|
+
return _defineProperty({}, path, [{
|
2114
|
+
message: "Expected 'array', got 'null'",
|
2115
|
+
typeError: true
|
2116
|
+
}]);
|
2117
|
+
}
|
2118
|
+
var current = {};
|
2119
|
+
var typeErrorRes = this.recursiveValidate(path, nodes, current);
|
2120
|
+
if (typeErrorRes) {
|
2121
|
+
return typeErrorRes;
|
2122
|
+
}
|
2123
|
+
if (Object.keys(current).length > 0) {
|
2124
|
+
return current;
|
2125
|
+
}
|
2126
|
+
return false;
|
2127
|
+
}
|
2128
|
+
}, {
|
2129
|
+
key: "recursiveValidate",
|
2130
|
+
value: function recursiveValidate(rootPath, nodes, current) {
|
2131
|
+
var addError = function addError(path, message, typeError) {
|
2132
|
+
if (!current[path]) {
|
2133
|
+
current[path] = [];
|
2134
|
+
}
|
2135
|
+
current[path].push({
|
2136
|
+
message: message,
|
2137
|
+
typeError: typeError
|
2138
|
+
});
|
2139
|
+
};
|
2140
|
+
var _iterator = _createForOfIteratorHelper(nodes),
|
2141
|
+
_step;
|
2142
|
+
try {
|
2143
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
2144
|
+
var _this$options$block, _this$options$block2, _this$options$block3, _this$options$block4, _this$options$block5, _this$options$block6, _this$options$block7, _this$options$block8, _this$options$block9, _this$options$block10, _this$options$inline, _this$options$inline2;
|
2145
|
+
var node = _step.value;
|
2146
|
+
var path = unsafeCreateSourcePath(rootPath, nodes.indexOf(node));
|
2147
|
+
if (typeof node === "string") {
|
2148
|
+
continue;
|
2149
|
+
}
|
2150
|
+
if (_typeof(node) !== "object") {
|
2151
|
+
return _defineProperty({}, path, [{
|
2152
|
+
message: "Expected nodes of type 'object' or 'string', got '".concat(_typeof(node), "'"),
|
2153
|
+
typeError: true
|
2154
|
+
}]);
|
2155
|
+
}
|
2156
|
+
if (node === null) {
|
2157
|
+
return _defineProperty({}, path, [{
|
2158
|
+
message: "Expected nodes of type 'object' or 'string', got 'null'",
|
2159
|
+
typeError: true
|
2160
|
+
}]);
|
2161
|
+
}
|
2162
|
+
if (!("tag" in node)) {
|
2163
|
+
return _defineProperty({}, path, [{
|
2164
|
+
message: "Expected node to either have 'tag' or be of type 'string'",
|
2165
|
+
typeError: true
|
2166
|
+
}]);
|
2167
|
+
}
|
2168
|
+
if (typeof node.tag !== "string") {
|
2169
|
+
return _defineProperty({}, path, [{
|
2170
|
+
message: "Expected 'string', got '".concat(_typeof(node.tag), "'"),
|
2171
|
+
typeError: true
|
2172
|
+
}]);
|
2173
|
+
}
|
2174
|
+
if (node.tag === "h1" && !((_this$options$block = this.options.block) !== null && _this$options$block !== void 0 && _this$options$block.h1)) {
|
2175
|
+
addError(path, "'h' block is not valid", false);
|
2176
|
+
}
|
2177
|
+
if (node.tag === "h2" && !((_this$options$block2 = this.options.block) !== null && _this$options$block2 !== void 0 && _this$options$block2.h2)) {
|
2178
|
+
addError(path, "'h2' block is not valid", false);
|
2179
|
+
}
|
2180
|
+
if (node.tag === "h3" && !((_this$options$block3 = this.options.block) !== null && _this$options$block3 !== void 0 && _this$options$block3.h3)) {
|
2181
|
+
addError(path, "'h3' block is not valid", false);
|
2182
|
+
}
|
2183
|
+
if (node.tag === "h4" && !((_this$options$block4 = this.options.block) !== null && _this$options$block4 !== void 0 && _this$options$block4.h4)) {
|
2184
|
+
addError(path, "'h4' block is not valid", false);
|
2185
|
+
}
|
2186
|
+
if (node.tag === "h5" && !((_this$options$block5 = this.options.block) !== null && _this$options$block5 !== void 0 && _this$options$block5.h5)) {
|
2187
|
+
addError(path, "'h5' block is not valid", false);
|
2188
|
+
}
|
2189
|
+
if (node.tag === "h6" && !((_this$options$block6 = this.options.block) !== null && _this$options$block6 !== void 0 && _this$options$block6.h6)) {
|
2190
|
+
addError(path, "'h6' block is not valid", false);
|
2191
|
+
}
|
2192
|
+
if (node.tag === "ol" && !((_this$options$block7 = this.options.block) !== null && _this$options$block7 !== void 0 && _this$options$block7.ol)) {
|
2193
|
+
addError(path, "'ol' block is not valid", false);
|
2194
|
+
}
|
2195
|
+
if (node.tag === "ul" && !((_this$options$block8 = this.options.block) !== null && _this$options$block8 !== void 0 && _this$options$block8.ul)) {
|
2196
|
+
addError(path, "'ul' block is not valid", false);
|
2197
|
+
}
|
2198
|
+
if (node.tag === "li" && !((_this$options$block9 = this.options.block) !== null && _this$options$block9 !== void 0 && _this$options$block9.ul) && !((_this$options$block10 = this.options.block) !== null && _this$options$block10 !== void 0 && _this$options$block10.ol)) {
|
2199
|
+
addError(path, "'li' tag is invalid since neither 'ul' nor 'ol' block is not valid", false);
|
2200
|
+
}
|
2201
|
+
if (node.tag === "a" && !((_this$options$inline = this.options.inline) !== null && _this$options$inline !== void 0 && _this$options$inline.a)) {
|
2202
|
+
addError(path, "'a' inline is not valid", false);
|
2203
|
+
}
|
2204
|
+
if (node.tag === "img" && !((_this$options$inline2 = this.options.inline) !== null && _this$options$inline2 !== void 0 && _this$options$inline2.img)) {
|
2205
|
+
addError(path, "'img' inline is not valid", false);
|
2206
|
+
}
|
2207
|
+
if ("styles" in node && node.tag !== "span") {
|
2208
|
+
return _defineProperty({}, path, [{
|
2209
|
+
message: "Cannot have styles on '".concat(node.tag, "'. This is only allowed on 'span'"),
|
2210
|
+
typeError: true
|
2211
|
+
}]);
|
2212
|
+
}
|
2213
|
+
if ("styles" in node) {
|
2214
|
+
if (!Array.isArray(node.styles)) {
|
2215
|
+
return _defineProperty({}, path, [{
|
2216
|
+
message: "Expected 'array', got '".concat(_typeof(node.styles), "'"),
|
2217
|
+
typeError: true
|
2218
|
+
}]);
|
2219
|
+
}
|
2220
|
+
var stylesPath = unsafeCreateSourcePath(path, "styles");
|
2221
|
+
for (var i = 0; i < node.styles.length; i++) {
|
2222
|
+
var _this$options$style, _this$options$style2, _this$options$style3;
|
2223
|
+
var style = node.styles[i];
|
2224
|
+
var currentStylePath = unsafeCreateSourcePath(stylesPath, i);
|
2225
|
+
if (typeof style !== "string") {
|
2226
|
+
return _defineProperty({}, currentStylePath, [{
|
2227
|
+
message: "Expected 'string', got '".concat(_typeof(style), "'"),
|
2228
|
+
typeError: true
|
2229
|
+
}]);
|
2230
|
+
}
|
2231
|
+
if (style === "bold" && !((_this$options$style = this.options.style) !== null && _this$options$style !== void 0 && _this$options$style.bold)) {
|
2232
|
+
addError(currentStylePath, "Style 'bold' is not valid", false);
|
2233
|
+
}
|
2234
|
+
if (style === "italic" && !((_this$options$style2 = this.options.style) !== null && _this$options$style2 !== void 0 && _this$options$style2.italic)) {
|
2235
|
+
addError(currentStylePath, "Style 'italic' is not valid", false);
|
2236
|
+
}
|
2237
|
+
if (style === "lineThrough" && !((_this$options$style3 = this.options.style) !== null && _this$options$style3 !== void 0 && _this$options$style3.lineThrough)) {
|
2238
|
+
addError(currentStylePath, "Style 'lineThrough' is not valid", false);
|
2239
|
+
}
|
2240
|
+
}
|
2241
|
+
}
|
2242
|
+
if ("children" in node) {
|
2243
|
+
if (!Array.isArray(node.children)) {
|
2244
|
+
return _defineProperty({}, path, [{
|
2245
|
+
message: "Expected 'array', got '".concat(_typeof(node.children), "'"),
|
2246
|
+
typeError: true
|
2247
|
+
}]);
|
2248
|
+
}
|
2249
|
+
var children = node.children;
|
2250
|
+
for (var _i = 0; _i < children.length; _i++) {
|
2251
|
+
var child = children[_i];
|
2252
|
+
if (_typeof(child) === "object") {
|
2253
|
+
var childPath = unsafeCreateSourcePath(path, "children");
|
2254
|
+
var res = this.recursiveValidate(childPath, [child], current);
|
2255
|
+
if (res) {
|
2256
|
+
return res;
|
2257
|
+
}
|
2258
|
+
} else if (typeof child !== "string") {
|
2259
|
+
return _defineProperty({}, path, [{
|
2260
|
+
message: "Expected 'object' or 'string', got '".concat(_typeof(child), "'"),
|
2261
|
+
typeError: true
|
2262
|
+
}]);
|
2263
|
+
}
|
2264
|
+
}
|
2265
|
+
}
|
2266
|
+
}
|
2267
|
+
} catch (err) {
|
2268
|
+
_iterator.e(err);
|
2269
|
+
} finally {
|
2270
|
+
_iterator.f();
|
2271
|
+
}
|
2109
2272
|
return false;
|
2110
2273
|
}
|
2111
2274
|
}, {
|
@@ -2117,6 +2280,15 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2117
2280
|
data: src
|
2118
2281
|
};
|
2119
2282
|
}
|
2283
|
+
if (src === null && !this.opt) {
|
2284
|
+
return {
|
2285
|
+
success: false,
|
2286
|
+
errors: _defineProperty({}, path, [{
|
2287
|
+
message: "Expected 'array', got 'null'",
|
2288
|
+
typeError: true
|
2289
|
+
}])
|
2290
|
+
};
|
2291
|
+
}
|
2120
2292
|
if (!Array.isArray(src)) {
|
2121
2293
|
return {
|
2122
2294
|
success: false,
|
@@ -2227,10 +2399,10 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2227
2399
|
typeError: true
|
2228
2400
|
});
|
2229
2401
|
} else {
|
2230
|
-
for (var
|
2231
|
-
var style = node.styles[
|
2402
|
+
for (var _i2 = 0; _i2 < node.styles.length; _i2++) {
|
2403
|
+
var style = node.styles[_i2];
|
2232
2404
|
if (typeof style !== "string") {
|
2233
|
-
var _pathAtError = unsafeCreateSourcePath(path,
|
2405
|
+
var _pathAtError = unsafeCreateSourcePath(path, _i2);
|
2234
2406
|
if (!errors[_pathAtError]) {
|
2235
2407
|
errors[_pathAtError] = [];
|
2236
2408
|
}
|
@@ -3147,6 +3319,21 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
3147
3319
|
}]);
|
3148
3320
|
}
|
3149
3321
|
}
|
3322
|
+
if (serializedSchema.type === "record") {
|
3323
|
+
if (typeof src !== "string") {
|
3324
|
+
return _defineProperty({}, path, [{
|
3325
|
+
message: "Value of keyOf (record) must be 'string'. Found: ".concat(_typeof(src))
|
3326
|
+
}]);
|
3327
|
+
}
|
3328
|
+
return _defineProperty({}, path, [{
|
3329
|
+
fixes: ["keyof:check-keys"],
|
3330
|
+
message: "Did not validate keyOf (record). This error (keyof:check-keys) should typically be processed by Val internally. Seeing this error most likely means you have a Val version mismatch.",
|
3331
|
+
value: {
|
3332
|
+
key: src,
|
3333
|
+
sourcePath: this.sourcePath
|
3334
|
+
}
|
3335
|
+
}]);
|
3336
|
+
}
|
3150
3337
|
return false;
|
3151
3338
|
}
|
3152
3339
|
}, {
|
@@ -2107,7 +2107,170 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2107
2107
|
if (!assertRes.success) {
|
2108
2108
|
return _defineProperty({}, path, assertRes.errors[path]);
|
2109
2109
|
}
|
2110
|
-
|
2110
|
+
var nodes = assertRes.data;
|
2111
|
+
if (nodes === null && this.opt) {
|
2112
|
+
return false;
|
2113
|
+
}
|
2114
|
+
if (nodes === null) {
|
2115
|
+
return _defineProperty({}, path, [{
|
2116
|
+
message: "Expected 'array', got 'null'",
|
2117
|
+
typeError: true
|
2118
|
+
}]);
|
2119
|
+
}
|
2120
|
+
var current = {};
|
2121
|
+
var typeErrorRes = this.recursiveValidate(path, nodes, current);
|
2122
|
+
if (typeErrorRes) {
|
2123
|
+
return typeErrorRes;
|
2124
|
+
}
|
2125
|
+
if (Object.keys(current).length > 0) {
|
2126
|
+
return current;
|
2127
|
+
}
|
2128
|
+
return false;
|
2129
|
+
}
|
2130
|
+
}, {
|
2131
|
+
key: "recursiveValidate",
|
2132
|
+
value: function recursiveValidate(rootPath, nodes, current) {
|
2133
|
+
var addError = function addError(path, message, typeError) {
|
2134
|
+
if (!current[path]) {
|
2135
|
+
current[path] = [];
|
2136
|
+
}
|
2137
|
+
current[path].push({
|
2138
|
+
message: message,
|
2139
|
+
typeError: typeError
|
2140
|
+
});
|
2141
|
+
};
|
2142
|
+
var _iterator = result._createForOfIteratorHelper(nodes),
|
2143
|
+
_step;
|
2144
|
+
try {
|
2145
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
2146
|
+
var _this$options$block, _this$options$block2, _this$options$block3, _this$options$block4, _this$options$block5, _this$options$block6, _this$options$block7, _this$options$block8, _this$options$block9, _this$options$block10, _this$options$inline, _this$options$inline2;
|
2147
|
+
var node = _step.value;
|
2148
|
+
var path = unsafeCreateSourcePath(rootPath, nodes.indexOf(node));
|
2149
|
+
if (typeof node === "string") {
|
2150
|
+
continue;
|
2151
|
+
}
|
2152
|
+
if (_typeof(node) !== "object") {
|
2153
|
+
return _defineProperty({}, path, [{
|
2154
|
+
message: "Expected nodes of type 'object' or 'string', got '".concat(_typeof(node), "'"),
|
2155
|
+
typeError: true
|
2156
|
+
}]);
|
2157
|
+
}
|
2158
|
+
if (node === null) {
|
2159
|
+
return _defineProperty({}, path, [{
|
2160
|
+
message: "Expected nodes of type 'object' or 'string', got 'null'",
|
2161
|
+
typeError: true
|
2162
|
+
}]);
|
2163
|
+
}
|
2164
|
+
if (!("tag" in node)) {
|
2165
|
+
return _defineProperty({}, path, [{
|
2166
|
+
message: "Expected node to either have 'tag' or be of type 'string'",
|
2167
|
+
typeError: true
|
2168
|
+
}]);
|
2169
|
+
}
|
2170
|
+
if (typeof node.tag !== "string") {
|
2171
|
+
return _defineProperty({}, path, [{
|
2172
|
+
message: "Expected 'string', got '".concat(_typeof(node.tag), "'"),
|
2173
|
+
typeError: true
|
2174
|
+
}]);
|
2175
|
+
}
|
2176
|
+
if (node.tag === "h1" && !((_this$options$block = this.options.block) !== null && _this$options$block !== void 0 && _this$options$block.h1)) {
|
2177
|
+
addError(path, "'h' block is not valid", false);
|
2178
|
+
}
|
2179
|
+
if (node.tag === "h2" && !((_this$options$block2 = this.options.block) !== null && _this$options$block2 !== void 0 && _this$options$block2.h2)) {
|
2180
|
+
addError(path, "'h2' block is not valid", false);
|
2181
|
+
}
|
2182
|
+
if (node.tag === "h3" && !((_this$options$block3 = this.options.block) !== null && _this$options$block3 !== void 0 && _this$options$block3.h3)) {
|
2183
|
+
addError(path, "'h3' block is not valid", false);
|
2184
|
+
}
|
2185
|
+
if (node.tag === "h4" && !((_this$options$block4 = this.options.block) !== null && _this$options$block4 !== void 0 && _this$options$block4.h4)) {
|
2186
|
+
addError(path, "'h4' block is not valid", false);
|
2187
|
+
}
|
2188
|
+
if (node.tag === "h5" && !((_this$options$block5 = this.options.block) !== null && _this$options$block5 !== void 0 && _this$options$block5.h5)) {
|
2189
|
+
addError(path, "'h5' block is not valid", false);
|
2190
|
+
}
|
2191
|
+
if (node.tag === "h6" && !((_this$options$block6 = this.options.block) !== null && _this$options$block6 !== void 0 && _this$options$block6.h6)) {
|
2192
|
+
addError(path, "'h6' block is not valid", false);
|
2193
|
+
}
|
2194
|
+
if (node.tag === "ol" && !((_this$options$block7 = this.options.block) !== null && _this$options$block7 !== void 0 && _this$options$block7.ol)) {
|
2195
|
+
addError(path, "'ol' block is not valid", false);
|
2196
|
+
}
|
2197
|
+
if (node.tag === "ul" && !((_this$options$block8 = this.options.block) !== null && _this$options$block8 !== void 0 && _this$options$block8.ul)) {
|
2198
|
+
addError(path, "'ul' block is not valid", false);
|
2199
|
+
}
|
2200
|
+
if (node.tag === "li" && !((_this$options$block9 = this.options.block) !== null && _this$options$block9 !== void 0 && _this$options$block9.ul) && !((_this$options$block10 = this.options.block) !== null && _this$options$block10 !== void 0 && _this$options$block10.ol)) {
|
2201
|
+
addError(path, "'li' tag is invalid since neither 'ul' nor 'ol' block is not valid", false);
|
2202
|
+
}
|
2203
|
+
if (node.tag === "a" && !((_this$options$inline = this.options.inline) !== null && _this$options$inline !== void 0 && _this$options$inline.a)) {
|
2204
|
+
addError(path, "'a' inline is not valid", false);
|
2205
|
+
}
|
2206
|
+
if (node.tag === "img" && !((_this$options$inline2 = this.options.inline) !== null && _this$options$inline2 !== void 0 && _this$options$inline2.img)) {
|
2207
|
+
addError(path, "'img' inline is not valid", false);
|
2208
|
+
}
|
2209
|
+
if ("styles" in node && node.tag !== "span") {
|
2210
|
+
return _defineProperty({}, path, [{
|
2211
|
+
message: "Cannot have styles on '".concat(node.tag, "'. This is only allowed on 'span'"),
|
2212
|
+
typeError: true
|
2213
|
+
}]);
|
2214
|
+
}
|
2215
|
+
if ("styles" in node) {
|
2216
|
+
if (!Array.isArray(node.styles)) {
|
2217
|
+
return _defineProperty({}, path, [{
|
2218
|
+
message: "Expected 'array', got '".concat(_typeof(node.styles), "'"),
|
2219
|
+
typeError: true
|
2220
|
+
}]);
|
2221
|
+
}
|
2222
|
+
var stylesPath = unsafeCreateSourcePath(path, "styles");
|
2223
|
+
for (var i = 0; i < node.styles.length; i++) {
|
2224
|
+
var _this$options$style, _this$options$style2, _this$options$style3;
|
2225
|
+
var style = node.styles[i];
|
2226
|
+
var currentStylePath = unsafeCreateSourcePath(stylesPath, i);
|
2227
|
+
if (typeof style !== "string") {
|
2228
|
+
return _defineProperty({}, currentStylePath, [{
|
2229
|
+
message: "Expected 'string', got '".concat(_typeof(style), "'"),
|
2230
|
+
typeError: true
|
2231
|
+
}]);
|
2232
|
+
}
|
2233
|
+
if (style === "bold" && !((_this$options$style = this.options.style) !== null && _this$options$style !== void 0 && _this$options$style.bold)) {
|
2234
|
+
addError(currentStylePath, "Style 'bold' is not valid", false);
|
2235
|
+
}
|
2236
|
+
if (style === "italic" && !((_this$options$style2 = this.options.style) !== null && _this$options$style2 !== void 0 && _this$options$style2.italic)) {
|
2237
|
+
addError(currentStylePath, "Style 'italic' is not valid", false);
|
2238
|
+
}
|
2239
|
+
if (style === "lineThrough" && !((_this$options$style3 = this.options.style) !== null && _this$options$style3 !== void 0 && _this$options$style3.lineThrough)) {
|
2240
|
+
addError(currentStylePath, "Style 'lineThrough' is not valid", false);
|
2241
|
+
}
|
2242
|
+
}
|
2243
|
+
}
|
2244
|
+
if ("children" in node) {
|
2245
|
+
if (!Array.isArray(node.children)) {
|
2246
|
+
return _defineProperty({}, path, [{
|
2247
|
+
message: "Expected 'array', got '".concat(_typeof(node.children), "'"),
|
2248
|
+
typeError: true
|
2249
|
+
}]);
|
2250
|
+
}
|
2251
|
+
var children = node.children;
|
2252
|
+
for (var _i = 0; _i < children.length; _i++) {
|
2253
|
+
var child = children[_i];
|
2254
|
+
if (_typeof(child) === "object") {
|
2255
|
+
var childPath = unsafeCreateSourcePath(path, "children");
|
2256
|
+
var res = this.recursiveValidate(childPath, [child], current);
|
2257
|
+
if (res) {
|
2258
|
+
return res;
|
2259
|
+
}
|
2260
|
+
} else if (typeof child !== "string") {
|
2261
|
+
return _defineProperty({}, path, [{
|
2262
|
+
message: "Expected 'object' or 'string', got '".concat(_typeof(child), "'"),
|
2263
|
+
typeError: true
|
2264
|
+
}]);
|
2265
|
+
}
|
2266
|
+
}
|
2267
|
+
}
|
2268
|
+
}
|
2269
|
+
} catch (err) {
|
2270
|
+
_iterator.e(err);
|
2271
|
+
} finally {
|
2272
|
+
_iterator.f();
|
2273
|
+
}
|
2111
2274
|
return false;
|
2112
2275
|
}
|
2113
2276
|
}, {
|
@@ -2119,6 +2282,15 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2119
2282
|
data: src
|
2120
2283
|
};
|
2121
2284
|
}
|
2285
|
+
if (src === null && !this.opt) {
|
2286
|
+
return {
|
2287
|
+
success: false,
|
2288
|
+
errors: _defineProperty({}, path, [{
|
2289
|
+
message: "Expected 'array', got 'null'",
|
2290
|
+
typeError: true
|
2291
|
+
}])
|
2292
|
+
};
|
2293
|
+
}
|
2122
2294
|
if (!Array.isArray(src)) {
|
2123
2295
|
return {
|
2124
2296
|
success: false,
|
@@ -2229,10 +2401,10 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2229
2401
|
typeError: true
|
2230
2402
|
});
|
2231
2403
|
} else {
|
2232
|
-
for (var
|
2233
|
-
var style = node.styles[
|
2404
|
+
for (var _i2 = 0; _i2 < node.styles.length; _i2++) {
|
2405
|
+
var style = node.styles[_i2];
|
2234
2406
|
if (typeof style !== "string") {
|
2235
|
-
var _pathAtError = unsafeCreateSourcePath(path,
|
2407
|
+
var _pathAtError = unsafeCreateSourcePath(path, _i2);
|
2236
2408
|
if (!errors[_pathAtError]) {
|
2237
2409
|
errors[_pathAtError] = [];
|
2238
2410
|
}
|
@@ -3149,6 +3321,21 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
3149
3321
|
}]);
|
3150
3322
|
}
|
3151
3323
|
}
|
3324
|
+
if (serializedSchema.type === "record") {
|
3325
|
+
if (typeof src !== "string") {
|
3326
|
+
return _defineProperty({}, path, [{
|
3327
|
+
message: "Value of keyOf (record) must be 'string'. Found: ".concat(_typeof(src))
|
3328
|
+
}]);
|
3329
|
+
}
|
3330
|
+
return _defineProperty({}, path, [{
|
3331
|
+
fixes: ["keyof:check-keys"],
|
3332
|
+
message: "Did not validate keyOf (record). This error (keyof:check-keys) should typically be processed by Val internally. Seeing this error most likely means you have a Val version mismatch.",
|
3333
|
+
value: {
|
3334
|
+
key: src,
|
3335
|
+
sourcePath: this.sourcePath
|
3336
|
+
}
|
3337
|
+
}]);
|
3338
|
+
}
|
3152
3339
|
return false;
|
3153
3340
|
}
|
3154
3341
|
}, {
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('./index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('./index-380b80a1.cjs.prod.js');
|
6
6
|
require('./result-787e35f6.cjs.prod.js');
|
7
7
|
|
8
8
|
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export { A as ArraySchema, B as BooleanSchema, D as DateSchema, F as FATAL_ERROR_TYPES, k as FILE_REF_PROP, l as FILE_REF_SUBTYPE_TAG, t as FileSchema, G as GenericSelector, r as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, q as NumberSchema, O as ObjectSchema, R as RecordSchema, u as RichTextSchema, j as Schema, o as StringSchema, U as UnionSchema, V as VAL_EXTENSION, n as derefPatch, v as deserializeSchema, i as expr, h as initVal, m as modules } from './index-
|
1
|
+
export { A as ArraySchema, B as BooleanSchema, D as DateSchema, F as FATAL_ERROR_TYPES, k as FILE_REF_PROP, l as FILE_REF_SUBTYPE_TAG, t as FileSchema, G as GenericSelector, r as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, q as NumberSchema, O as ObjectSchema, R as RecordSchema, u as RichTextSchema, j as Schema, o as StringSchema, U as UnionSchema, V as VAL_EXTENSION, n as derefPatch, v as deserializeSchema, i as expr, h as initVal, m as modules } from './index-7218e8b1.esm.js';
|
2
2
|
import './result-168dfc1d.esm.js';
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-7ae61742.cjs.dev.js');
|
6
6
|
require('../../dist/result-bb1f436e.cjs.dev.js');
|
7
7
|
|
8
8
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-380b80a1.cjs.prod.js');
|
6
6
|
require('../../dist/result-787e35f6.cjs.prod.js');
|
7
7
|
|
8
8
|
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export { C as Call, E as Expr, N as NilSym, S as StringLiteral, e as StringTemplate, f as Sym, g as evaluate, p as parse } from '../../dist/index-
|
1
|
+
export { C as Call, E as Expr, N as NilSym, S as StringLiteral, e as StringTemplate, f as Sym, g as evaluate, p as parse } from '../../dist/index-7218e8b1.esm.js';
|
2
2
|
import '../../dist/result-168dfc1d.esm.js';
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-7ae61742.cjs.dev.js');
|
6
6
|
var result = require('../../dist/result-bb1f436e.cjs.dev.js');
|
7
7
|
var util = require('../../dist/util-b213092b.cjs.dev.js');
|
8
8
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-380b80a1.cjs.prod.js');
|
6
6
|
var result = require('../../dist/result-787e35f6.cjs.prod.js');
|
7
7
|
var util = require('../../dist/util-030d8a1f.cjs.prod.js');
|
8
8
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-
|
2
|
-
export { P as PatchError } from '../../dist/index-
|
1
|
+
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-7218e8b1.esm.js';
|
2
|
+
export { P as PatchError } from '../../dist/index-7218e8b1.esm.js';
|
3
3
|
import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-168dfc1d.esm.js';
|
4
4
|
import { p as pipe } from '../../dist/util-18613e99.esm.js';
|
5
5
|
|