@bookinglab/booking-ui-react 1.14.0 → 1.15.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.
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -485,6 +485,24 @@ function BookingForm({
|
|
|
485
485
|
return `Maximum value is ${question.settings.max}`;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
+
if (question.detail_type === "date" && question.dateLimiter?.enabled && typeof value === "string" && value !== "") {
|
|
489
|
+
const toDatePart = (iso) => {
|
|
490
|
+
if (!iso || typeof iso !== "string") return null;
|
|
491
|
+
const m = iso.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
492
|
+
return m ? m[1] : null;
|
|
493
|
+
};
|
|
494
|
+
const min = toDatePart(question.dateLimiter.minimumDate);
|
|
495
|
+
const max = toDatePart(question.dateLimiter.maximumDate);
|
|
496
|
+
const v = value;
|
|
497
|
+
const outOfRange = min && v < min || max && v > max;
|
|
498
|
+
if (outOfRange) {
|
|
499
|
+
if (question.dateLimiter.errorText) return question.dateLimiter.errorText;
|
|
500
|
+
if (min && max) return `Date must be between ${min} and ${max}`;
|
|
501
|
+
if (min) return `Date must be on or after ${min}`;
|
|
502
|
+
if (max) return `Date must be on or before ${max}`;
|
|
503
|
+
return "Date is outside the allowed range";
|
|
504
|
+
}
|
|
505
|
+
}
|
|
488
506
|
return null;
|
|
489
507
|
}, []);
|
|
490
508
|
const validateAll = useCallback(() => {
|