@railway-ts/pipelines 0.1.25 → 0.1.26
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/schema/index.cjs +18 -0
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +35 -1
- package/dist/schema/index.d.ts +35 -1
- package/dist/schema/index.mjs +17 -1
- package/dist/schema/index.mjs.map +1 -1
- package/docs/API.md +100 -13
- package/docs/RECIPES.md +30 -1
- package/package.json +1 -1
package/dist/schema/index.cjs
CHANGED
|
@@ -266,6 +266,22 @@ function refineAtAsync(targetPath, predicate, message) {
|
|
|
266
266
|
return ok(value);
|
|
267
267
|
};
|
|
268
268
|
}
|
|
269
|
+
function when(predicate, thenValidator, elseValidator) {
|
|
270
|
+
return (value, path = []) => {
|
|
271
|
+
if (predicate(value)) {
|
|
272
|
+
return thenValidator(value, path);
|
|
273
|
+
}
|
|
274
|
+
return elseValidator ? elseValidator(value, path) : ok(value);
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
function whenAsync(predicate, thenValidator, elseValidator) {
|
|
278
|
+
return async (value, path = []) => {
|
|
279
|
+
if (predicate(value)) {
|
|
280
|
+
return thenValidator(value, path);
|
|
281
|
+
}
|
|
282
|
+
return elseValidator ? elseValidator(value, path) : ok(value);
|
|
283
|
+
};
|
|
284
|
+
}
|
|
269
285
|
|
|
270
286
|
// src/schema/string.ts
|
|
271
287
|
function string(message = "Must be a string") {
|
|
@@ -1147,5 +1163,7 @@ exports.url = url;
|
|
|
1147
1163
|
exports.uuid = uuid;
|
|
1148
1164
|
exports.validate = validate;
|
|
1149
1165
|
exports.validateAndFormatResult = validateAndFormatResult;
|
|
1166
|
+
exports.when = when;
|
|
1167
|
+
exports.whenAsync = whenAsync;
|
|
1150
1168
|
//# sourceMappingURL=index.cjs.map
|
|
1151
1169
|
//# sourceMappingURL=index.cjs.map
|