@railway-ts/pipelines 0.1.23 → 0.1.24
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 +85 -3
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +73 -3
- package/dist/schema/index.d.ts +73 -3
- package/dist/schema/index.mjs +81 -4
- package/dist/schema/index.mjs.map +1 -1
- package/docs/API.md +40 -0
- package/docs/RECIPES.md +21 -0
- package/package.json +1 -1
package/docs/API.md
CHANGED
|
@@ -902,6 +902,46 @@ function phoneNumber(message?: string): Validator<string>;
|
|
|
902
902
|
|
|
903
903
|
Ensure a string is a valid phone number. Accepts international formats with `+`, spaces, dashes, and parentheses.
|
|
904
904
|
|
|
905
|
+
#### `uuid`
|
|
906
|
+
|
|
907
|
+
```typescript
|
|
908
|
+
function uuid(message?: string): Validator<string>;
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
Ensure a string is a valid RFC 4122 UUID.
|
|
912
|
+
|
|
913
|
+
#### `isoDate`
|
|
914
|
+
|
|
915
|
+
```typescript
|
|
916
|
+
function isoDate(message?: string): Validator<string>;
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
Ensure a string is a valid ISO 8601 date (`YYYY-MM-DD`). Validates both format and calendar correctness (rejects Feb 30, etc.).
|
|
920
|
+
|
|
921
|
+
#### `isoTime`
|
|
922
|
+
|
|
923
|
+
```typescript
|
|
924
|
+
function isoTime(message?: string): Validator<string>;
|
|
925
|
+
```
|
|
926
|
+
|
|
927
|
+
Ensure a string is a valid ISO 8601 / RFC 3339 time. Format: `HH:mm:ss[.fractional][Z|±HH:mm]`. Timezone is optional.
|
|
928
|
+
|
|
929
|
+
#### `isoDateTime`
|
|
930
|
+
|
|
931
|
+
```typescript
|
|
932
|
+
function isoDateTime(message?: string): Validator<string>;
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
Ensure a string is a valid ISO 8601 / RFC 3339 datetime. Format: `YYYY-MM-DDTHH:mm:ss[.fractional][Z|±HH:mm]`. Validates both date calendar correctness and time bounds.
|
|
936
|
+
|
|
937
|
+
#### `isoDuration`
|
|
938
|
+
|
|
939
|
+
```typescript
|
|
940
|
+
function isoDuration(message?: string): Validator<string>;
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
Ensure a string is a valid ISO 8601 duration (`PnYnMnDTnHnMnS` or `PnW`).
|
|
944
|
+
|
|
905
945
|
### Number Constraints
|
|
906
946
|
|
|
907
947
|
#### `min`
|
package/docs/RECIPES.md
CHANGED
|
@@ -645,6 +645,27 @@ const birthDate = chain(parseDate(), pastDate());
|
|
|
645
645
|
const eventDate = chain(parseISODate(), dateRange(new Date('2025-01-01'), new Date('2025-12-31')));
|
|
646
646
|
```
|
|
647
647
|
|
|
648
|
+
### String Format Validators
|
|
649
|
+
|
|
650
|
+
```typescript
|
|
651
|
+
import { chain, string, uuid, isoDate, isoTime, isoDateTime, isoDuration } from '@railway-ts/pipelines/schema';
|
|
652
|
+
|
|
653
|
+
// UUID
|
|
654
|
+
const id = chain(string(), uuid());
|
|
655
|
+
|
|
656
|
+
// ISO date (YYYY-MM-DD)
|
|
657
|
+
const dateStr = chain(string(), isoDate());
|
|
658
|
+
|
|
659
|
+
// ISO time with optional timezone
|
|
660
|
+
const timeStr = chain(string(), isoTime());
|
|
661
|
+
|
|
662
|
+
// Full ISO datetime
|
|
663
|
+
const timestamp = chain(string(), isoDateTime());
|
|
664
|
+
|
|
665
|
+
// ISO duration (e.g. P1Y2M3DT4H5M6S)
|
|
666
|
+
const duration = chain(string(), isoDuration());
|
|
667
|
+
```
|
|
668
|
+
|
|
648
669
|
### Empty-String Handling
|
|
649
670
|
|
|
650
671
|
`emptyAsOptional` treats empty strings (and `null`/`undefined`) as `undefined` instead of failing validation. Useful for HTML forms where blank fields submit as `""`:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@railway-ts/pipelines",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
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": {
|