@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/docs/API.md CHANGED
@@ -1266,6 +1266,23 @@ Run a validator against a value. Returns sync when the validator is sync.
1266
1266
 
1267
1267
  Pass `{ abortEarly: true }` to stop on the first validation error instead of collecting all errors. The third argument can be either a base `path` (string array) for error reporting, or an options object. When both are needed, pass `path` third and `options` fourth.
1268
1268
 
1269
+ #### `is`
1270
+
1271
+ ```typescript
1272
+ function is(value: unknown, validator: Validator<unknown, unknown>): boolean;
1273
+ function is(value: unknown, validator: MaybeAsyncValidator<unknown, unknown>): boolean | Promise<boolean>;
1274
+ ```
1275
+
1276
+ Check if a value passes validation. Returns `true` if valid, `false` if not. Shorthand for `isOk(validate(value, validator))`.
1277
+
1278
+ Uses `abortEarly` internally for efficiency — stops on the first error. Returns a `Promise<boolean>` when given an async validator.
1279
+
1280
+ ```typescript
1281
+ is('hello', string()); // true
1282
+ is(42, string()); // false
1283
+ await is('dave', asyncValidator); // true (async)
1284
+ ```
1285
+
1269
1286
  #### `validateAndFormatResult`
1270
1287
 
1271
1288
  ```typescript
@@ -245,6 +245,18 @@ match(result, {
245
245
  >
246
246
  > See [Recipes: Abort Early](RECIPES.md#abort-early) for details.
247
247
 
248
+ > **Tip:** If you only need a boolean (pass/fail), use `is()`:
249
+ >
250
+ > ```typescript
251
+ > import { is } from '@railway-ts/pipelines/schema';
252
+ >
253
+ > if (is(input, userSchema)) {
254
+ > // input is valid
255
+ > }
256
+ > ```
257
+ >
258
+ > See [API Reference: `is`](API.md#is) for details.
259
+
248
260
  ---
249
261
 
250
262
  ## Step 7: Putting It All Together
package/docs/RECIPES.md CHANGED
@@ -285,6 +285,33 @@ const result = validateAndFormatResult(input, userSchema, { abortEarly: true });
285
285
 
286
286
  `abortEarly` propagates through nested `object()`, `array()`, `tuple()`, and `tupleOf()` validators — the entire tree stops as soon as the first error is found.
287
287
 
288
+ ### Quick Validity Check
289
+
290
+ Use `is()` when you only need a boolean — no error details, no `Result` unwrapping:
291
+
292
+ ```typescript
293
+ import { is, string, chain, minLength, object, required, email } from '@railway-ts/pipelines/schema';
294
+
295
+ // Primitives
296
+ is('hello', string()); // true
297
+ is(42, string()); // false
298
+
299
+ // Composed validators
300
+ const shortString = chain(string(), minLength(5));
301
+ is('hello', shortString); // true
302
+ is('hi', shortString); // false
303
+
304
+ // Objects
305
+ const userSchema = object({
306
+ name: required(chain(string(), minLength(2))),
307
+ email: required(chain(string(), email())),
308
+ });
309
+ is({ name: 'Alice', email: 'alice@example.com' }, userSchema); // true
310
+ is({ name: 'Alice', email: 'nope' }, userSchema); // false
311
+ ```
312
+
313
+ `is()` uses `abortEarly` internally — it short-circuits on the first error since you only need pass/fail.
314
+
288
315
  ### Conditional Validation
289
316
 
290
317
  ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@railway-ts/pipelines",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "Railway-oriented pipelines for TypeScript: a lightweight fp-style Result/Option and schema layer for handling errors and validating boundaries.",
5
5
  "type": "module",
6
6
  "exports": {