function validate()

in public/src/js/utils/drag-dispatcher.js [191:219]


function validate (sourceItem, newItems, context) {
    if (sourceItem.type === vars.CONST.draggableTypes.configCollection) {
        return Promise.resolve();
    } else {
        var maxChars = vars.CONST.restrictedHeadlineLength || 90,
            restrictHeadlinesOn = vars.CONST.restrictHeadlinesOn || [],
            restrictedLiveMode = vars.CONST.restrictedLiveMode || [];

        return capi.validateItem(newItems[0])
        .then(item => {
            var front = context ? context.front() : '',
                err;

            if (item.group.parentType === 'Collection') {
                if (restrictHeadlinesOn.indexOf(front) > -1 && (item.meta.headline() || item.fields.headline()).length > maxChars) {
                    err = 'Sorry, a ' + front + ' headline must be ' + maxChars + ' characters or less. Edit it first within the clipboard.';
                }
                if (restrictedLiveMode.indexOf(front) > -1 && context.mode() === 'live') {
                    err = 'Sorry, ' + front + ' items cannot be added in Live Front mode. Switch to Draft Front then try again.';
                }
                if (err) {
                    return Promise.reject(err);
                }

                return context.newItemValidator(item);
            }
        });
    }
}