While setting up events on a client site we found that an editor can't save a whole-day event that starts and ends on the same day. Tick "Whole Day", set 2 December to 2 December, and the form refuses to save:
Event start date must be on or before 02 Dec 2026, 02:00
Event end date must be on or after 02 Dec 2026, 02:00
The message says "on or before", and the dates are equal, so the editor has done exactly what it asks.
Diagnosis
The block happens in the browser, before anything reaches the backend. Volto 18 registers two client-side validators for plone.eventbasic in helpers/FormValidation/validators.ts, and both use strict comparisons:
// startEventDateRangeValidator
value && formData.end && new Date(value) < new Date(formData.end);
// endEventDateRangeValidator
value && formData.start && new Date(value) > new Date(formData.start);
With "Whole Day" ticked, DatetimeWidget sends both dates as YYYY-MM-DD. Same day, same string, same timestamp, so neither check passes. (The "02:00" in the message is midnight UTC shown in South African time.)
It isn't only whole-day events. Any event with an identical start and end time fails the same way.
The backend is fine with equal dates. plone.app.event's invariant only rejects start > end.
We saw this on Volto 18.35.0, and the code on main is the same today.
Workaround
Volto's validators are registry utilities, and registering a utility with the same name and dependencies replaces it. Add-on configuration loads after Volto's own, so in your add-on's config:
import { messages } from '@plone/volto/helpers/MessageLabels/MessageLabels';
const formatDateValue = (isoString) => {
const date = new Date(isoString);
if (isNaN(date.getTime())) return isoString;
return new Intl.DateTimeFormat(undefined, {
dateStyle: 'medium',
timeStyle: 'short',
}).format(date);
};
const startEventDateRangeValidator = ({ value, formData, formatMessage }) => {
const isValid =
value && formData.end && new Date(value) <= new Date(formData.end);
return !isValid
? formatMessage(messages.startEventRange, {
endDateValueOrEndFieldName: formData.end
? formatDateValue(formData.end)
: 'end',
})
: null;
};
const endEventDateRangeValidator = ({ value, formData, formatMessage }) => {
const isValid =
value && formData.start && new Date(value) >= new Date(formData.start);
return !isValid
? formatMessage(messages.endEventRange, {
startDateValueOrStartFieldName: formData.start
? formatDateValue(formData.start)
: 'start',
})
: null;
};
export default function applyConfig(config) {
config.registerUtility({
name: 'dateRangeValidator',
type: 'validator',
dependencies: { behaviorName: 'plone.eventbasic', fieldName: 'start' },
method: startEventDateRangeValidator,
});
config.registerUtility({
name: 'dateRangeValidator',
type: 'validator',
dependencies: { behaviorName: 'plone.eventbasic', fieldName: 'end' },
method: endEventDateRangeValidator,
});
return config;
}
The only change from Volto's version is <= and >=.
Upstream
The real fix is those two characters in Volto. I'm happy to open the PR unless someone knows of a reason the comparison was made strict.