Skip to content

Commit e358183

Browse files
committed
added validation to keyword input and implement it with space seperator
1 parent bce82ea commit e358183

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/components/ui/CreateModelModal.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,13 @@ export const CreateModelModal: React.FC<CreateModelModalProps> = ({
369369
return;
370370
}
371371

372+
// Validate keywords
373+
const keywords = formData.keywords.trim().split(/\s+/).filter(k => k.length > 0);
374+
if (keywords.length === 0) {
375+
setError('Please enter at least one keyword');
376+
return;
377+
}
378+
372379
setIsLoading(true);
373380
setError('');
374381

@@ -377,7 +384,7 @@ export const CreateModelModal: React.FC<CreateModelModalProps> = ({
377384
name: formData.name.trim(),
378385
description: formData.description.trim(),
379386
domain: formData.domain.trim(),
380-
keyword: formData.keywords.split(',').map(k => k.trim()).filter(k => k.length > 0),
387+
keyword: keywords,
381388
ecoreFileId: uploadedFileIds.ecoreFileId,
382389
genModelFileId: uploadedFileIds.genModelFileId,
383390
};
@@ -472,13 +479,16 @@ export const CreateModelModal: React.FC<CreateModelModalProps> = ({
472479
<label style={labelStyle}>Keywords</label>
473480
<input
474481
type="text"
475-
placeholder="Enter keywords separated by commas"
482+
placeholder="Enter keywords separated by spaces (e.g., modeling design architecture)"
476483
value={formData.keywords}
477484
onChange={(e) => setFormData({ ...formData, keywords: e.target.value })}
478485
style={inputStyle}
479486
onFocus={(e) => Object.assign(e.currentTarget.style, inputFocusStyle)}
480487
onBlur={(e) => Object.assign(e.currentTarget.style, inputStyle)}
481488
/>
489+
<div style={{ fontSize: '12px', color: '#666', marginTop: '4px', fontStyle: 'italic' }}>
490+
Note: Use spaces to separate multiple keywords. Each keyword will be added to the array.
491+
</div>
482492
</div>
483493

484494
<div style={formGroupStyle}>

0 commit comments

Comments
 (0)