@railway-ts/pipelines 0.1.23 → 0.1.25

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.
@@ -712,8 +712,8 @@ declare function pattern(regex: RegExp, message?: string): Validator<string>;
712
712
  * @example
713
713
  * const validate = nonEmpty();
714
714
  * validate('John'); // ok("John")
715
- * validate(''); // err([{ path: [], message: 'String must not be empty' }])
716
- * validate(' '); // err([{ path: [], message: 'String must not be empty' }])
715
+ * validate(''); // err([{ path: [], message: 'Field must not be empty' }])
716
+ * validate(' '); // err([{ path: [], message: 'Field must not be empty' }])
717
717
  *
718
718
  * @param message - Custom error message
719
719
  * @returns A validator that checks if a string is not empty
@@ -756,6 +756,76 @@ declare function url(message?: string): Validator<string>;
756
756
  * @returns A validator that checks if a string is a valid phone number
757
757
  */
758
758
  declare function phoneNumber(message?: string): Validator<string>;
759
+ /**
760
+ * Create a validator that ensures a string is a valid UUID (RFC 4122).
761
+ * Accepts any UUID version including NIL UUIDs (all zeros).
762
+ *
763
+ * @example
764
+ * const validate = uuid();
765
+ * validate('550e8400-e29b-41d4-a716-446655440000'); // ok(...)
766
+ * validate('not-a-uuid'); // err([{ path: [], message: 'Invalid UUID format' }])
767
+ *
768
+ * @param message - Custom error message
769
+ * @returns A validator that checks if a string is a valid UUID
770
+ */
771
+ declare function uuid(message?: string): Validator<string>;
772
+ /**
773
+ * Create a validator that ensures a string is a valid ISO 8601 date (YYYY-MM-DD).
774
+ * Validates both format and calendar correctness (e.g., rejects Feb 30).
775
+ *
776
+ * @example
777
+ * const validate = isoDate();
778
+ * validate('2024-01-15'); // ok("2024-01-15")
779
+ * validate('2024-02-30'); // err([{ path: [], message: 'Invalid ISO date format' }])
780
+ *
781
+ * @param message - Custom error message
782
+ * @returns A validator that checks if a string is a valid ISO date
783
+ */
784
+ declare function isoDate(message?: string): Validator<string>;
785
+ /**
786
+ * Create a validator that ensures a string is a valid ISO 8601 / RFC 3339 time.
787
+ * Format: `HH:mm:ss[.fractional][Z|±HH:mm]`. Timezone is optional.
788
+ *
789
+ * @example
790
+ * const validate = isoTime();
791
+ * validate('14:30:00'); // ok("14:30:00")
792
+ * validate('14:30:00Z'); // ok("14:30:00Z")
793
+ * validate('14:30:00+05:30'); // ok("14:30:00+05:30")
794
+ * validate('25:00:00'); // err([{ path: [], message: 'Invalid ISO time format' }])
795
+ *
796
+ * @param message - Custom error message
797
+ * @returns A validator that checks if a string is a valid ISO time
798
+ */
799
+ declare function isoTime(message?: string): Validator<string>;
800
+ /**
801
+ * Create a validator that ensures a string is a valid ISO 8601 / RFC 3339 datetime.
802
+ * Format: `YYYY-MM-DDTHH:mm:ss[.fractional][Z|±HH:mm]`.
803
+ *
804
+ * @example
805
+ * const validate = isoDateTime();
806
+ * validate('2024-01-15T14:30:00Z'); // ok(...)
807
+ * validate('2024-01-15T14:30:00+05:30'); // ok(...)
808
+ * validate('2024-02-30T14:30:00Z'); // err([{ path: [], message: 'Invalid ISO datetime format' }])
809
+ *
810
+ * @param message - Custom error message
811
+ * @returns A validator that checks if a string is a valid ISO datetime
812
+ */
813
+ declare function isoDateTime(message?: string): Validator<string>;
814
+ /**
815
+ * Create a validator that ensures a string is a valid ISO 8601 duration.
816
+ * Format: `PnYnMnDTnHnMnS` or `PnW`.
817
+ *
818
+ * @example
819
+ * const validate = isoDuration();
820
+ * validate('P1Y2M3D'); // ok("P1Y2M3D")
821
+ * validate('PT1H30M'); // ok("PT1H30M")
822
+ * validate('P4W'); // ok("P4W")
823
+ * validate('P'); // err([{ path: [], message: 'Invalid ISO duration format' }])
824
+ *
825
+ * @param message - Custom error message
826
+ * @returns A validator that checks if a string is a valid ISO duration
827
+ */
828
+ declare function isoDuration(message?: string): Validator<string>;
759
829
 
760
830
  /**
761
831
  * Create a validator that parses input into a number.
@@ -1158,4 +1228,4 @@ declare namespace StandardSchemaV1 {
1158
1228
  declare function toStandardSchema<O>(validator: Validator<unknown, O>): StandardSchemaV1<unknown, O>;
1159
1229
  declare function toStandardSchema<O>(validator: MaybeAsyncValidator<unknown, O>): StandardSchemaV1<unknown, O>;
1160
1230
 
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 };
1231
+ 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, isoDate, isoDateTime, isoDuration, isoTime, 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, uuid, validate, validateAndFormatResult };
@@ -712,8 +712,8 @@ declare function pattern(regex: RegExp, message?: string): Validator<string>;
712
712
  * @example
713
713
  * const validate = nonEmpty();
714
714
  * validate('John'); // ok("John")
715
- * validate(''); // err([{ path: [], message: 'String must not be empty' }])
716
- * validate(' '); // err([{ path: [], message: 'String must not be empty' }])
715
+ * validate(''); // err([{ path: [], message: 'Field must not be empty' }])
716
+ * validate(' '); // err([{ path: [], message: 'Field must not be empty' }])
717
717
  *
718
718
  * @param message - Custom error message
719
719
  * @returns A validator that checks if a string is not empty
@@ -756,6 +756,76 @@ declare function url(message?: string): Validator<string>;
756
756
  * @returns A validator that checks if a string is a valid phone number
757
757
  */
758
758
  declare function phoneNumber(message?: string): Validator<string>;
759
+ /**
760
+ * Create a validator that ensures a string is a valid UUID (RFC 4122).
761
+ * Accepts any UUID version including NIL UUIDs (all zeros).
762
+ *
763
+ * @example
764
+ * const validate = uuid();
765
+ * validate('550e8400-e29b-41d4-a716-446655440000'); // ok(...)
766
+ * validate('not-a-uuid'); // err([{ path: [], message: 'Invalid UUID format' }])
767
+ *
768
+ * @param message - Custom error message
769
+ * @returns A validator that checks if a string is a valid UUID
770
+ */
771
+ declare function uuid(message?: string): Validator<string>;
772
+ /**
773
+ * Create a validator that ensures a string is a valid ISO 8601 date (YYYY-MM-DD).
774
+ * Validates both format and calendar correctness (e.g., rejects Feb 30).
775
+ *
776
+ * @example
777
+ * const validate = isoDate();
778
+ * validate('2024-01-15'); // ok("2024-01-15")
779
+ * validate('2024-02-30'); // err([{ path: [], message: 'Invalid ISO date format' }])
780
+ *
781
+ * @param message - Custom error message
782
+ * @returns A validator that checks if a string is a valid ISO date
783
+ */
784
+ declare function isoDate(message?: string): Validator<string>;
785
+ /**
786
+ * Create a validator that ensures a string is a valid ISO 8601 / RFC 3339 time.
787
+ * Format: `HH:mm:ss[.fractional][Z|±HH:mm]`. Timezone is optional.
788
+ *
789
+ * @example
790
+ * const validate = isoTime();
791
+ * validate('14:30:00'); // ok("14:30:00")
792
+ * validate('14:30:00Z'); // ok("14:30:00Z")
793
+ * validate('14:30:00+05:30'); // ok("14:30:00+05:30")
794
+ * validate('25:00:00'); // err([{ path: [], message: 'Invalid ISO time format' }])
795
+ *
796
+ * @param message - Custom error message
797
+ * @returns A validator that checks if a string is a valid ISO time
798
+ */
799
+ declare function isoTime(message?: string): Validator<string>;
800
+ /**
801
+ * Create a validator that ensures a string is a valid ISO 8601 / RFC 3339 datetime.
802
+ * Format: `YYYY-MM-DDTHH:mm:ss[.fractional][Z|±HH:mm]`.
803
+ *
804
+ * @example
805
+ * const validate = isoDateTime();
806
+ * validate('2024-01-15T14:30:00Z'); // ok(...)
807
+ * validate('2024-01-15T14:30:00+05:30'); // ok(...)
808
+ * validate('2024-02-30T14:30:00Z'); // err([{ path: [], message: 'Invalid ISO datetime format' }])
809
+ *
810
+ * @param message - Custom error message
811
+ * @returns A validator that checks if a string is a valid ISO datetime
812
+ */
813
+ declare function isoDateTime(message?: string): Validator<string>;
814
+ /**
815
+ * Create a validator that ensures a string is a valid ISO 8601 duration.
816
+ * Format: `PnYnMnDTnHnMnS` or `PnW`.
817
+ *
818
+ * @example
819
+ * const validate = isoDuration();
820
+ * validate('P1Y2M3D'); // ok("P1Y2M3D")
821
+ * validate('PT1H30M'); // ok("PT1H30M")
822
+ * validate('P4W'); // ok("P4W")
823
+ * validate('P'); // err([{ path: [], message: 'Invalid ISO duration format' }])
824
+ *
825
+ * @param message - Custom error message
826
+ * @returns A validator that checks if a string is a valid ISO duration
827
+ */
828
+ declare function isoDuration(message?: string): Validator<string>;
759
829
 
760
830
  /**
761
831
  * Create a validator that parses input into a number.
@@ -1158,4 +1228,4 @@ declare namespace StandardSchemaV1 {
1158
1228
  declare function toStandardSchema<O>(validator: Validator<unknown, O>): StandardSchemaV1<unknown, O>;
1159
1229
  declare function toStandardSchema<O>(validator: MaybeAsyncValidator<unknown, O>): StandardSchemaV1<unknown, O>;
1160
1230
 
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 };
1231
+ 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, isoDate, isoDateTime, isoDuration, isoTime, 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, uuid, validate, validateAndFormatResult };
@@ -298,7 +298,7 @@ function pattern(regex, message = "Invalid format") {
298
298
  return ok(value);
299
299
  };
300
300
  }
301
- function nonEmpty(message = "String must not be empty") {
301
+ function nonEmpty(message = "Field must not be empty") {
302
302
  return (value, path = []) => {
303
303
  if (value.trim().length === 0) {
304
304
  return err([{ path, message }]);
@@ -321,10 +321,87 @@ function url(message = "Invalid URL format") {
321
321
  };
322
322
  }
323
323
  function phoneNumber(message = "Invalid phone number format") {
324
- const phoneRegex = /^\+?[\d\s\-()]{8,20}$/;
324
+ const phoneRegex = /^\+?[\d\-()]{8,20}$/;
325
325
  return (value, path = []) => {
326
326
  const cleanedValue = value.replaceAll(/\s+/g, "");
327
- if (!phoneRegex.test(cleanedValue)) {
327
+ if (!phoneRegex.test(cleanedValue) || cleanedValue.replaceAll(/\D/g, "").length < 7) {
328
+ return err([{ path, message }]);
329
+ }
330
+ return ok(value);
331
+ };
332
+ }
333
+ function uuid(message = "Invalid UUID format") {
334
+ const uuidRegex = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
335
+ return pattern(uuidRegex, message);
336
+ }
337
+ function isoDate(message = "Invalid ISO date format") {
338
+ const isoDateRegex = /^\d{4}-\d{2}-\d{2}$/;
339
+ return (value, path = []) => {
340
+ if (!isoDateRegex.test(value)) {
341
+ return err([{ path, message }]);
342
+ }
343
+ const date2 = /* @__PURE__ */ new Date(value + "T00:00:00Z");
344
+ if (Number.isNaN(date2.getTime()) || date2.toISOString().slice(0, 10) !== value) {
345
+ return err([{ path, message }]);
346
+ }
347
+ return ok(value);
348
+ };
349
+ }
350
+ function isoTime(message = "Invalid ISO time format") {
351
+ const isoTimeRegex = /^(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|([+-])(\d{2}):(\d{2}))?$/;
352
+ return (value, path = []) => {
353
+ const match2 = isoTimeRegex.exec(value);
354
+ if (!match2) {
355
+ return err([{ path, message }]);
356
+ }
357
+ const hours = Number(match2[1]);
358
+ const minutes = Number(match2[2]);
359
+ const seconds = Number(match2[3]);
360
+ if (hours > 23 || minutes > 59 || seconds > 59) {
361
+ return err([{ path, message }]);
362
+ }
363
+ if (match2[4]) {
364
+ const tzHours = Number(match2[5]);
365
+ const tzMinutes = Number(match2[6]);
366
+ if (tzHours > 23 || tzMinutes > 59) {
367
+ return err([{ path, message }]);
368
+ }
369
+ }
370
+ return ok(value);
371
+ };
372
+ }
373
+ function isoDateTime(message = "Invalid ISO datetime format") {
374
+ const isoDateTimeRegex = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|([+-])(\d{2}):(\d{2}))?$/;
375
+ return (value, path = []) => {
376
+ const match2 = isoDateTimeRegex.exec(value);
377
+ if (!match2) {
378
+ return err([{ path, message }]);
379
+ }
380
+ const datePart = match2[1];
381
+ const date2 = /* @__PURE__ */ new Date(datePart + "T00:00:00Z");
382
+ if (Number.isNaN(date2.getTime()) || date2.toISOString().slice(0, 10) !== datePart) {
383
+ return err([{ path, message }]);
384
+ }
385
+ const hours = Number(match2[2]);
386
+ const minutes = Number(match2[3]);
387
+ const seconds = Number(match2[4]);
388
+ if (hours > 23 || minutes > 59 || seconds > 59) {
389
+ return err([{ path, message }]);
390
+ }
391
+ if (match2[5]) {
392
+ const tzHours = Number(match2[6]);
393
+ const tzMinutes = Number(match2[7]);
394
+ if (tzHours > 23 || tzMinutes > 59) {
395
+ return err([{ path, message }]);
396
+ }
397
+ }
398
+ return ok(value);
399
+ };
400
+ }
401
+ function isoDuration(message = "Invalid ISO duration format") {
402
+ const isoDurationRegex = /^P(?:\d+W|(?:\d+Y)?(?:\d+M)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+(?:\.\d+)?S)?)?)$/;
403
+ return (value, path = []) => {
404
+ if (!isoDurationRegex.test(value) || value === "P" || value.endsWith("T")) {
328
405
  return err([{ path, message }]);
329
406
  }
330
407
  return ok(value);
@@ -994,6 +1071,6 @@ function toStandardSchema(validator) {
994
1071
  };
995
1072
  }
996
1073
 
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 };
1074
+ export { ROOT_ERROR_KEY, _getAbortEarly, _withAbortEarly, array, between, bigint, boolean, chain, chainAsync, date, dateRange, discriminatedUnion, divisibleBy, email, emptyAsOptional, enumValue, finite, formatErrors, futureDate, integer, is, isoDate, isoDateTime, isoDuration, isoTime, 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, uuid, validate, validateAndFormatResult };
998
1075
  //# sourceMappingURL=index.mjs.map
999
1076
  //# sourceMappingURL=index.mjs.map