diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index 5f041a7c..dc3e50e7 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -455,6 +455,7 @@ export const en = { recommend: 'Recommend', logoTip: `Supported image formats: JPG, PNG \n Suggested size: square ratio \n Maximum size: ≤ 2MB`, imageSquareRequired: 'Please upload a square image', + nameInvalid: 'Name cannot start or end with a space', }, model: { searchPlaceholder: 'search model…', @@ -545,7 +546,6 @@ export const en = { xinference: "Xinference", gpustack: "Gpustack", bedrock: "Bedrock", - nameInvalid: 'Model name can only contain letters, numbers, underscores and spaces, cannot be empty or pure whitespace', }, modelNew: { group: 'Model Group', diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts index 0c0f7562..dea8ae2e 100644 --- a/web/src/i18n/zh.ts +++ b/web/src/i18n/zh.ts @@ -1034,6 +1034,7 @@ export const zh = { recommend: '推荐', logoTip: `支持图片格式(JPG、PNG)\n 尺寸:正方形比例 \n 文件大小限制:≤ 2MB`, imageSquareRequired: '请上传正方形比例图片', + nameInvalid: '不能是空格开头或结尾', }, model: { searchPlaceholder: '搜索模型…', @@ -1182,7 +1183,6 @@ export const zh = { xinference: "Xinference", gpustack: "Gpustack", bedrock: "Bedrock", - nameInvalid: '模型名称只能包含字母、数字、下划线和空格, 不能为空或纯空格', }, timezones: { 'Asia/Shanghai': '中国标准时间 (UTC+8)', diff --git a/web/src/utils/validator.ts b/web/src/utils/validator.ts index c55c52ca..650266ab 100644 --- a/web/src/utils/validator.ts +++ b/web/src/utils/validator.ts @@ -45,6 +45,5 @@ export const validateSquareImage = (errorMessage: string = 'Image must be square }; }; -// - Cannot be empty or pure whitespace -// - Cannot start with a space -export const stringRegExp = /^[a-zA-Z0-9\u4e00-\u9fa5][a-zA-Z0-9\u4e00-\u9fa5\s]*$/ \ No newline at end of file +// - Cannot start or end with a space +export const stringRegExp = /^(?!\s).*(?