tripstorekrabi-shared 1.2.0 → 1.5.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils.js +8 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.2.0",
3
+ "version": "1.5.0",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer",
6
6
  "repository": {
package/utils.js CHANGED
@@ -404,7 +404,7 @@ export function getItemSummary(item, product) {
404
404
  return summary;
405
405
  }
406
406
 
407
- export function validateSchedule(schedule, schedules = []) {
407
+ export function validateSchedule(schedule, schedules = [], context) {
408
408
  if (schedule === "?") {
409
409
  return true;
410
410
  } else if (schedule.indexOf(" - ") != -1) {
@@ -413,16 +413,19 @@ export function validateSchedule(schedule, schedules = []) {
413
413
  var to = times[1];
414
414
 
415
415
  if (!SCHEDULE_PATTERN.test(from) || !SCHEDULE_PATTERN.test(to) || (from === to)) {
416
- return "Invalid schedule format: for example use '09:00 - 15:30'";
416
+ return context.createError({ message: "Invalid schedule format: for example use '09:00 - 15:30'", path: context.path, });
417
417
  }
418
418
  } else {
419
- return "Invalid schedule format: for example use '09:00 - 15:30'";
419
+ return context.createError({ message: "Invalid schedule format: for example use '09:00 - 15:30'", path: context.path, });
420
420
  }
421
421
 
422
-
423
422
  if (schedule != "") {
424
423
  if (schedules.length > 0 && schedules.indexOf(schedule) == -1) {
425
- return { status: "warning", message: "The value does not match the product schedules" };
424
+ return context.createError({
425
+ message: "The value does not match the product schedules",
426
+ path: context.path,
427
+ params: { status: "warning" },
428
+ });
426
429
  }
427
430
  }
428
431
 
@@ -473,10 +476,6 @@ function checkTime(pickupTimeValue, departureTimeValue) {
473
476
  }
474
477
  }
475
478
 
476
- export function hasCustomerEmail(email) {
477
- return email && email !== "info@tripstorekrabi.com";
478
- }
479
-
480
479
  export function isActivity(url) {
481
480
  return url.includes("/Activities/");
482
481
  }