Skip to content

Commit d926cc2

Browse files
authored
fix: enforce date validation for custom sections in edit mode (#1260)
Remove isEditMode bypass for start and end date validation. This ensures scheduled or live sections always have dates on or after today, even when editing existing sections, and validates manually typed dates that bypass the date picker's minDate constraint.
1 parent 8f3feeb commit d926cc2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/curated-corpus/components/CustomSectionForm/CustomSectionForm.validation.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ export const getValidationSchema = (isEditMode: boolean = false) => {
4545
'not-in-past',
4646
'Start date cannot be in the past',
4747
function (value) {
48-
// TODO(HNT-1125): Remove the edit-mode bypass and enforce start-date validation
49-
// for manually typed values once editorial confirms we should always require
50-
// startDate >= today for new and existing sections.
51-
if (!value || isEditMode) {
48+
// Always enforce start date validation, even in edit mode
49+
// This ensures scheduled or live sections always start on or after today
50+
if (!value) {
5251
return true;
5352
}
5453
const startDate = DateTime.fromJSDate(value).startOf('day');
@@ -60,7 +59,8 @@ export const getValidationSchema = (isEditMode: boolean = false) => {
6059
.date()
6160
.nullable()
6261
.test('not-in-past', 'End date cannot be in the past', function (value) {
63-
if (!value || isEditMode) {
62+
// Always enforce end date validation, even in edit mode
63+
if (!value) {
6464
return true;
6565
}
6666
const endDate = DateTime.fromJSDate(value).startOf('day');

0 commit comments

Comments
 (0)