@railway-ts/pipelines 0.1.22 → 0.1.23
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 +8 -0
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +16 -1
- package/dist/schema/index.d.ts +16 -1
- package/dist/schema/index.mjs +8 -1
- package/dist/schema/index.mjs.map +1 -1
- package/docs/API.md +17 -0
- package/docs/GETTING_STARTED.md +12 -0
- package/docs/RECIPES.md +27 -0
- package/package.json +1 -1
package/dist/schema/index.d.cts
CHANGED
|
@@ -246,6 +246,21 @@ declare function validate<T>(value: unknown, validator: MaybeAsyncValidator<unkn
|
|
|
246
246
|
declare function validate<T>(value: unknown, validator: MaybeAsyncValidator<unknown, T>, path: string[]): Result<T, ValidationError[]> | Promise<Result<T, ValidationError[]>>;
|
|
247
247
|
declare function validate<T>(value: unknown, validator: MaybeAsyncValidator<unknown, T>, options: ValidateOptions): Result<T, ValidationError[]> | Promise<Result<T, ValidationError[]>>;
|
|
248
248
|
declare function validate<T>(value: unknown, validator: MaybeAsyncValidator<unknown, T>, path: string[], options: ValidateOptions): Result<T, ValidationError[]> | Promise<Result<T, ValidationError[]>>;
|
|
249
|
+
/**
|
|
250
|
+
* Check whether a value satisfies a validator, returning a boolean.
|
|
251
|
+
* Always short-circuits on first error for maximum performance.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* is('hello', string()); // true
|
|
255
|
+
* is(42, string()); // false
|
|
256
|
+
* is(input, asyncValidator()); // Promise<boolean>
|
|
257
|
+
*
|
|
258
|
+
* @param value - The value to check
|
|
259
|
+
* @param validator - The validator to apply
|
|
260
|
+
* @returns `true` if valid, `false` otherwise (or a Promise for async validators)
|
|
261
|
+
*/
|
|
262
|
+
declare function is(value: unknown, validator: Validator<unknown, unknown>): boolean;
|
|
263
|
+
declare function is(value: unknown, validator: MaybeAsyncValidator<unknown, unknown>): boolean | Promise<boolean>;
|
|
249
264
|
/**
|
|
250
265
|
* Format validation errors into a user-friendly object.
|
|
251
266
|
* Converts array paths to dot/bracket notation strings.
|
|
@@ -1143,4 +1158,4 @@ declare namespace StandardSchemaV1 {
|
|
|
1143
1158
|
declare function toStandardSchema<O>(validator: Validator<unknown, O>): StandardSchemaV1<unknown, O>;
|
|
1144
1159
|
declare function toStandardSchema<O>(validator: MaybeAsyncValidator<unknown, O>): StandardSchemaV1<unknown, O>;
|
|
1145
1160
|
|
|
1146
|
-
export { type AsyncValidator, type InferSchemaType, type MaybeAsyncValidator, ROOT_ERROR_KEY, type Schema, StandardSchemaV1, type SyncSchema, type ValidateOptions, type ValidationError, type ValidationResult, type Validator, type ValidatorMapOutput, array, between, bigint, boolean, chain, chainAsync, date, dateRange, discriminatedUnion, divisibleBy, email, emptyAsOptional, enumValue, finite, formatErrors, futureDate, integer, literal, matches, max, maxItems, maxLength, min, minItems, minLength, negative, nonEmpty, nonZero, notEmpty, nullable, number, object, oneOf, optional, parseBigInt, parseBool, parseDate, parseEnum, parseISODate, parseJSON, parseNumber, parseString, parseURL, pastDate, pattern, phoneNumber, positive, precision, refine, refineAsync, refineAt, refineAtAsync, required, string, stringEnum, toStandardSchema, todayOrFuture, transform, tuple, tupleOf, union, unique, url, validate, validateAndFormatResult };
|
|
1161
|
+
export { type AsyncValidator, type InferSchemaType, type MaybeAsyncValidator, ROOT_ERROR_KEY, type Schema, StandardSchemaV1, type SyncSchema, type ValidateOptions, type ValidationError, type ValidationResult, type Validator, type ValidatorMapOutput, array, between, bigint, boolean, chain, chainAsync, date, dateRange, discriminatedUnion, divisibleBy, email, emptyAsOptional, enumValue, finite, formatErrors, futureDate, integer, is, literal, matches, max, maxItems, maxLength, min, minItems, minLength, negative, nonEmpty, nonZero, notEmpty, nullable, number, object, oneOf, optional, parseBigInt, parseBool, parseDate, parseEnum, parseISODate, parseJSON, parseNumber, parseString, parseURL, pastDate, pattern, phoneNumber, positive, precision, refine, refineAsync, refineAt, refineAtAsync, required, string, stringEnum, toStandardSchema, todayOrFuture, transform, tuple, tupleOf, union, unique, url, validate, validateAndFormatResult };
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -246,6 +246,21 @@ declare function validate<T>(value: unknown, validator: MaybeAsyncValidator<unkn
|
|
|
246
246
|
declare function validate<T>(value: unknown, validator: MaybeAsyncValidator<unknown, T>, path: string[]): Result<T, ValidationError[]> | Promise<Result<T, ValidationError[]>>;
|
|
247
247
|
declare function validate<T>(value: unknown, validator: MaybeAsyncValidator<unknown, T>, options: ValidateOptions): Result<T, ValidationError[]> | Promise<Result<T, ValidationError[]>>;
|
|
248
248
|
declare function validate<T>(value: unknown, validator: MaybeAsyncValidator<unknown, T>, path: string[], options: ValidateOptions): Result<T, ValidationError[]> | Promise<Result<T, ValidationError[]>>;
|
|
249
|
+
/**
|
|
250
|
+
* Check whether a value satisfies a validator, returning a boolean.
|
|
251
|
+
* Always short-circuits on first error for maximum performance.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* is('hello', string()); // true
|
|
255
|
+
* is(42, string()); // false
|
|
256
|
+
* is(input, asyncValidator()); // Promise<boolean>
|
|
257
|
+
*
|
|
258
|
+
* @param value - The value to check
|
|
259
|
+
* @param validator - The validator to apply
|
|
260
|
+
* @returns `true` if valid, `false` otherwise (or a Promise for async validators)
|
|
261
|
+
*/
|
|
262
|
+
declare function is(value: unknown, validator: Validator<unknown, unknown>): boolean;
|
|
263
|
+
declare function is(value: unknown, validator: MaybeAsyncValidator<unknown, unknown>): boolean | Promise<boolean>;
|
|
249
264
|
/**
|
|
250
265
|
* Format validation errors into a user-friendly object.
|
|
251
266
|
* Converts array paths to dot/bracket notation strings.
|
|
@@ -1143,4 +1158,4 @@ declare namespace StandardSchemaV1 {
|
|
|
1143
1158
|
declare function toStandardSchema<O>(validator: Validator<unknown, O>): StandardSchemaV1<unknown, O>;
|
|
1144
1159
|
declare function toStandardSchema<O>(validator: MaybeAsyncValidator<unknown, O>): StandardSchemaV1<unknown, O>;
|
|
1145
1160
|
|
|
1146
|
-
export { type AsyncValidator, type InferSchemaType, type MaybeAsyncValidator, ROOT_ERROR_KEY, type Schema, StandardSchemaV1, type SyncSchema, type ValidateOptions, type ValidationError, type ValidationResult, type Validator, type ValidatorMapOutput, array, between, bigint, boolean, chain, chainAsync, date, dateRange, discriminatedUnion, divisibleBy, email, emptyAsOptional, enumValue, finite, formatErrors, futureDate, integer, literal, matches, max, maxItems, maxLength, min, minItems, minLength, negative, nonEmpty, nonZero, notEmpty, nullable, number, object, oneOf, optional, parseBigInt, parseBool, parseDate, parseEnum, parseISODate, parseJSON, parseNumber, parseString, parseURL, pastDate, pattern, phoneNumber, positive, precision, refine, refineAsync, refineAt, refineAtAsync, required, string, stringEnum, toStandardSchema, todayOrFuture, transform, tuple, tupleOf, union, unique, url, validate, validateAndFormatResult };
|
|
1161
|
+
export { type AsyncValidator, type InferSchemaType, type MaybeAsyncValidator, ROOT_ERROR_KEY, type Schema, StandardSchemaV1, type SyncSchema, type ValidateOptions, type ValidationError, type ValidationResult, type Validator, type ValidatorMapOutput, array, between, bigint, boolean, chain, chainAsync, date, dateRange, discriminatedUnion, divisibleBy, email, emptyAsOptional, enumValue, finite, formatErrors, futureDate, integer, is, literal, matches, max, maxItems, maxLength, min, minItems, minLength, negative, nonEmpty, nonZero, notEmpty, nullable, number, object, oneOf, optional, parseBigInt, parseBool, parseDate, parseEnum, parseISODate, parseJSON, parseNumber, parseString, parseURL, pastDate, pattern, phoneNumber, positive, precision, refine, refineAsync, refineAt, refineAtAsync, required, string, stringEnum, toStandardSchema, todayOrFuture, transform, tuple, tupleOf, union, unique, url, validate, validateAndFormatResult };
|
package/dist/schema/index.mjs
CHANGED
|
@@ -183,6 +183,13 @@ function validate(value, validator, pathOrOptions = [], maybeOptions) {
|
|
|
183
183
|
}
|
|
184
184
|
return validator(value, path);
|
|
185
185
|
}
|
|
186
|
+
function is(value, validator) {
|
|
187
|
+
const result = _withAbortEarly(true, () => validator(value));
|
|
188
|
+
if (result instanceof Promise) {
|
|
189
|
+
return result.then((r) => r.ok);
|
|
190
|
+
}
|
|
191
|
+
return result.ok;
|
|
192
|
+
}
|
|
186
193
|
function formatErrors(errors) {
|
|
187
194
|
return errors.reduce(
|
|
188
195
|
(acc, error) => {
|
|
@@ -987,6 +994,6 @@ function toStandardSchema(validator) {
|
|
|
987
994
|
};
|
|
988
995
|
}
|
|
989
996
|
|
|
990
|
-
export { ROOT_ERROR_KEY, _getAbortEarly, _withAbortEarly, array, between, bigint, boolean, chain, chainAsync, date, dateRange, discriminatedUnion, divisibleBy, email, emptyAsOptional, enumValue, finite, formatErrors, futureDate, integer, literal, matches, max, maxItems, maxLength, min, minItems, minLength, negative, nonEmpty, nonZero, notEmpty, nullable, number, object, oneOf, optional, parseBigInt, parseBool, parseDate, parseEnum, parseISODate, parseJSON, parseNumber, parseString, parseURL, pastDate, pattern, phoneNumber, positive, precision, refine, refineAsync, refineAt, refineAtAsync, required, string, stringEnum, toStandardSchema, todayOrFuture, transform, tuple, tupleOf, union, unique, url, validate, validateAndFormatResult };
|
|
997
|
+
export { ROOT_ERROR_KEY, _getAbortEarly, _withAbortEarly, array, between, bigint, boolean, chain, chainAsync, date, dateRange, discriminatedUnion, divisibleBy, email, emptyAsOptional, enumValue, finite, formatErrors, futureDate, integer, is, literal, matches, max, maxItems, maxLength, min, minItems, minLength, negative, nonEmpty, nonZero, notEmpty, nullable, number, object, oneOf, optional, parseBigInt, parseBool, parseDate, parseEnum, parseISODate, parseJSON, parseNumber, parseString, parseURL, pastDate, pattern, phoneNumber, positive, precision, refine, refineAsync, refineAt, refineAtAsync, required, string, stringEnum, toStandardSchema, todayOrFuture, transform, tuple, tupleOf, union, unique, url, validate, validateAndFormatResult };
|
|
991
998
|
//# sourceMappingURL=index.mjs.map
|
|
992
999
|
//# sourceMappingURL=index.mjs.map
|