@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.
@@ -300,7 +300,7 @@ function pattern(regex, message = "Invalid format") {
300
300
  return ok(value);
301
301
  };
302
302
  }
303
- function nonEmpty(message = "String must not be empty") {
303
+ function nonEmpty(message = "Field must not be empty") {
304
304
  return (value, path = []) => {
305
305
  if (value.trim().length === 0) {
306
306
  return err([{ path, message }]);
@@ -323,10 +323,87 @@ function url(message = "Invalid URL format") {
323
323
  };
324
324
  }
325
325
  function phoneNumber(message = "Invalid phone number format") {
326
- const phoneRegex = /^\+?[\d\s\-()]{8,20}$/;
326
+ const phoneRegex = /^\+?[\d\-()]{8,20}$/;
327
327
  return (value, path = []) => {
328
328
  const cleanedValue = value.replaceAll(/\s+/g, "");
329
- if (!phoneRegex.test(cleanedValue)) {
329
+ if (!phoneRegex.test(cleanedValue) || cleanedValue.replaceAll(/\D/g, "").length < 7) {
330
+ return err([{ path, message }]);
331
+ }
332
+ return ok(value);
333
+ };
334
+ }
335
+ function uuid(message = "Invalid UUID format") {
336
+ const uuidRegex = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
337
+ return pattern(uuidRegex, message);
338
+ }
339
+ function isoDate(message = "Invalid ISO date format") {
340
+ const isoDateRegex = /^\d{4}-\d{2}-\d{2}$/;
341
+ return (value, path = []) => {
342
+ if (!isoDateRegex.test(value)) {
343
+ return err([{ path, message }]);
344
+ }
345
+ const date2 = /* @__PURE__ */ new Date(value + "T00:00:00Z");
346
+ if (Number.isNaN(date2.getTime()) || date2.toISOString().slice(0, 10) !== value) {
347
+ return err([{ path, message }]);
348
+ }
349
+ return ok(value);
350
+ };
351
+ }
352
+ function isoTime(message = "Invalid ISO time format") {
353
+ const isoTimeRegex = /^(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|([+-])(\d{2}):(\d{2}))?$/;
354
+ return (value, path = []) => {
355
+ const match2 = isoTimeRegex.exec(value);
356
+ if (!match2) {
357
+ return err([{ path, message }]);
358
+ }
359
+ const hours = Number(match2[1]);
360
+ const minutes = Number(match2[2]);
361
+ const seconds = Number(match2[3]);
362
+ if (hours > 23 || minutes > 59 || seconds > 59) {
363
+ return err([{ path, message }]);
364
+ }
365
+ if (match2[4]) {
366
+ const tzHours = Number(match2[5]);
367
+ const tzMinutes = Number(match2[6]);
368
+ if (tzHours > 23 || tzMinutes > 59) {
369
+ return err([{ path, message }]);
370
+ }
371
+ }
372
+ return ok(value);
373
+ };
374
+ }
375
+ function isoDateTime(message = "Invalid ISO datetime format") {
376
+ const isoDateTimeRegex = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|([+-])(\d{2}):(\d{2}))?$/;
377
+ return (value, path = []) => {
378
+ const match2 = isoDateTimeRegex.exec(value);
379
+ if (!match2) {
380
+ return err([{ path, message }]);
381
+ }
382
+ const datePart = match2[1];
383
+ const date2 = /* @__PURE__ */ new Date(datePart + "T00:00:00Z");
384
+ if (Number.isNaN(date2.getTime()) || date2.toISOString().slice(0, 10) !== datePart) {
385
+ return err([{ path, message }]);
386
+ }
387
+ const hours = Number(match2[2]);
388
+ const minutes = Number(match2[3]);
389
+ const seconds = Number(match2[4]);
390
+ if (hours > 23 || minutes > 59 || seconds > 59) {
391
+ return err([{ path, message }]);
392
+ }
393
+ if (match2[5]) {
394
+ const tzHours = Number(match2[6]);
395
+ const tzMinutes = Number(match2[7]);
396
+ if (tzHours > 23 || tzMinutes > 59) {
397
+ return err([{ path, message }]);
398
+ }
399
+ }
400
+ return ok(value);
401
+ };
402
+ }
403
+ function isoDuration(message = "Invalid ISO duration format") {
404
+ const isoDurationRegex = /^P(?:\d+W|(?:\d+Y)?(?:\d+M)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+(?:\.\d+)?S)?)?)$/;
405
+ return (value, path = []) => {
406
+ if (!isoDurationRegex.test(value) || value === "P" || value.endsWith("T")) {
330
407
  return err([{ path, message }]);
331
408
  }
332
409
  return ok(value);
@@ -1017,6 +1094,10 @@ exports.formatErrors = formatErrors;
1017
1094
  exports.futureDate = futureDate;
1018
1095
  exports.integer = integer;
1019
1096
  exports.is = is;
1097
+ exports.isoDate = isoDate;
1098
+ exports.isoDateTime = isoDateTime;
1099
+ exports.isoDuration = isoDuration;
1100
+ exports.isoTime = isoTime;
1020
1101
  exports.literal = literal;
1021
1102
  exports.matches = matches;
1022
1103
  exports.max = max;
@@ -1063,6 +1144,7 @@ exports.tupleOf = tupleOf;
1063
1144
  exports.union = union;
1064
1145
  exports.unique = unique;
1065
1146
  exports.url = url;
1147
+ exports.uuid = uuid;
1066
1148
  exports.validate = validate;
1067
1149
  exports.validateAndFormatResult = validateAndFormatResult;
1068
1150
  //# sourceMappingURL=index.cjs.map