Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

753 B
Raw Blame
import { useTranslation } from 'react-i18next'

const i18nPrefix = 'metadata.checkName'

const useCheckMetadataName = () => {
  const { t } = useTranslation(['dataset'])
  return {
    checkName: (name: string) => {
      if (!name) {
        return {
          errorMsg: t(($) => $[`${i18nPrefix}.empty`], { ns: 'dataset' }),
        }
      }

      if (!/^[a-z][a-z0-9_]*$/.test(name)) {
        return {
          errorMsg: t(($) => $[`${i18nPrefix}.invalid`], { ns: 'dataset' }),
        }
      }

      if (name.length > 255) {
        return {
          errorMsg: t(($) => $[`${i18nPrefix}.tooLong`], { ns: 'dataset', max: 255 }),
        }
      }

      return {
        errorMsg: '',
      }
    },
  }
}

export default useCheckMetadataName