You can validate the target size using the onEventResizing event handler that is fired during resizing in real-time (see also event resizing customization). The real-time validation needs to be performed synchronously on the client side.

This example forbids target sizes where the event spans multiple days and ensures none of the days overlap with a weekend.

onEventResizing: (args) => {
    const { newStart, newEnd } = args;

    const isWeekend = (date) => {
        const dayOfWeek = date.getDayOfWeek();
        return dayOfWeek === 0 || dayOfWeek === 6;  // Sunday or Saturday
    };

    let currentDate = newStart;
    let overlapsWeekend = false;

    while (currentDate < newEnd) {
        if (isWeekend(currentDate)) {
            overlapsWeekend = true;
            break;
        }
        currentDate = currentDate.addDays(1);
    }

    if (overlapsWeekend) {
        args.allowed = false;
    }
},

After resizing, you can validate the target size using the onEventResize event handler and cancel it if it doesn’t meet the rules.

This validation can be asynchronous, and you can call external services (e.g., a server-side API endpoint) to perform the validation.

onEventResize: async (args) => {
    args.async = true;
    const params = {
      id: args.e.id(),
      newStart: args.newStart,
      newEnd: args.newEnd,
      resource: args.e.resource()
    };
    const {data} = await DayPilot.Http.post("/api/checkResizeTarget", params);

    if (data.error) {
        dp.message(data.message);
        args.preventDefault();
    }
    args.loaded();
},