Skip to content

Commit

Permalink
LA-1358: Add validation for names ending with dot in workspace, workg…
Browse files Browse the repository at this point in the history
…roup, and folder creation/editing
  • Loading branch information
KhaledNjim authored and hoangdat committed Aug 21, 2024
1 parent e919e41 commit 12fcb7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions lib/presentation/util/extensions/linshare_node_type_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ extension LinShareNodeTypeExtension on LinShareNodeType {
return AppLocalizations.of(context).node_name_already_exists(AppLocalizations.of(context).workgroup);
} else if (exception is SpecialCharacterException) {
return AppLocalizations.of(context).node_name_contain_special_character(AppLocalizations.of(context).workgroup);
} else if (exception is LastDotException) {
return AppLocalizations.of(context).node_name_contain_last_dot(
AppLocalizations.of(context).workgroup);

} else {
return null;
}
Expand All @@ -67,6 +71,9 @@ extension LinShareNodeTypeExtension on LinShareNodeType {
return AppLocalizations.of(context).node_name_already_exists(AppLocalizations.of(context).workspace);
} else if (exception is SpecialCharacterException) {
return AppLocalizations.of(context).node_name_contain_special_character(AppLocalizations.of(context).workspace);
} else if (exception is LastDotException) {
return AppLocalizations.of(context).node_name_contain_last_dot(
AppLocalizations.of(context).workspace);
} else {
return null;
}
Expand All @@ -86,12 +93,14 @@ extension LinShareNodeTypeExtension on LinShareNodeType {
return [
EmptyNameValidator(),
DuplicateNameValidator(sharedSpaceNodes.map((node) => node.name).toList()),
SpecialCharacterValidator()
SpecialCharacterValidator(),
LastDotValidator()
];
case LinShareNodeType.WORK_SPACE:
return [
EmptyNameValidator(),
SpecialCharacterValidator()
SpecialCharacterValidator(),
LastDotValidator()
];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ class SharedSpaceDocumentNodeViewModel extends BaseViewModel {
EmptyNameValidator(),
DuplicateNameValidator(listName),
SpecialCharacterValidator(),
if (workGroupNode is WorkGroupDocument) LastDotValidator()
LastDotValidator()
]).fold((failure) {
if (failure is VerifyNameFailure) {
final nodeName = workGroupNode is WorkGroupDocument
Expand Down

0 comments on commit 12fcb7c

Please sign in to comment.