Skip to content

The open alternative to Salesforce, designed for AI.

450 B
Raw Blame
import { isNonEmptyString } from '@sniptt/guards';

import {
  AiException,
  AiExceptionCode,
} from 'src/engine/metadata-modules/ai/ai.exception';

export const validateAgentChatChannelNameOrThrow = (name: string): string => {
  const trimmedName = name.trim();

  if (!isNonEmptyString(trimmedName)) {
    throw new AiException(
      'A channel needs a name',
      AiExceptionCode.INVALID_CHAT_CHANNEL_NAME,
    );
  }

  return trimmedName;
};