This apps script allows to replace the , to | only if you set the advance option in data validation like below
function onEdit(e) {
const sh = e.value.replace(/,\s/g,"|");
if(e.range.getDataValidation())
{
var list = String(sh).split('|');
var uniq = [...new Set(list)];
e.range.clear();
e.range.setValue(uniq.join("|"));
}
}