fix: replace 6-word limit with 150-character limit for project names (#1077)
Replaces the word-based validation with character-based validation as originally requested in #971. The 6-word limit was causing issues with small words and separators being counted equally, and didn't match the original requirement for a character limit. Changes: - Backend: Replace wordCount validator with len validator (1-150 chars) - Frontend: Replace word count validation with character length check - UI already has line-clamp-3 for display truncation Fixes #998
This commit is contained in:
parent
9edbe142b6
commit
b1a0a728d2
2 changed files with 6 additions and 18 deletions
|
|
@ -23,17 +23,9 @@ module.exports = (sequelize) => {
|
||||||
notEmpty: {
|
notEmpty: {
|
||||||
msg: 'Project name is required',
|
msg: 'Project name is required',
|
||||||
},
|
},
|
||||||
wordCount(value) {
|
len: {
|
||||||
const MAX_WORDS = 6;
|
args: [1, 150],
|
||||||
const wordCount = value
|
msg: 'Project name must be between 1 and 150 characters',
|
||||||
.trim()
|
|
||||||
.split(/\s+/)
|
|
||||||
.filter((word) => word.length > 0).length;
|
|
||||||
if (wordCount > MAX_WORDS) {
|
|
||||||
throw new Error(
|
|
||||||
`Project name must be ${MAX_WORDS} words or less`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -268,16 +268,12 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_WORDS = 6;
|
const MAX_LENGTH = 150;
|
||||||
const wordCount = formData.name
|
if (formData.name.trim().length > MAX_LENGTH) {
|
||||||
.trim()
|
|
||||||
.split(/\s+/)
|
|
||||||
.filter((word) => word.length > 0).length;
|
|
||||||
if (wordCount > MAX_WORDS) {
|
|
||||||
setError(
|
setError(
|
||||||
t(
|
t(
|
||||||
'errors.projectNameTooLong',
|
'errors.projectNameTooLong',
|
||||||
`Project name must be ${MAX_WORDS} words or less`
|
`Project name must be ${MAX_LENGTH} characters or less`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue