Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Creating group chat with space only in name #2046

Open
dab246 opened this issue Sep 23, 2024 · 2 comments
Open

[BUG] Creating group chat with space only in name #2046

dab246 opened this issue Sep 23, 2024 · 2 comments
Assignees
Labels
bug Something isn't working QA::Minor

Comments

@dab246
Copy link
Member

dab246 commented Sep 23, 2024

Env:

  • Version: 2.6.5
  • Server: stg.lin-saas.com
  • Platform: Chrome, Edge(Macbook)

Steps to reproduce

  1. Click on the Pen icon at the bottom of the left sidebar
  2. Click “New group chat”
  3. Select one or multiple contact by checking the checkbox on the left
  4. Click ->
  5. Enter space in name input field
  6. Clicking Done icon to creates a group chat

Expectation

  • Please trim it before checking empty

Evidence

Screen.Recording.2024-09-23.at.11.56.37.mov
@dab246 dab246 added bug Something isn't working QA::Minor labels Sep 23, 2024
@hoangdat
Copy link
Member

  • should have validator for name of group chat in creating

@hoangdat
Copy link
Member

Desc:

Validator:

abstract class Validator<T> {
  Either<Failure, Success> validate(T value);
}

EmptyNameValidator

class EmptyNameValidator extends Validator<NewNameRequest> {

  @override
  Either<Failure, Success> validate(NewNameRequest value) {
    if (value.value == null || value.value!.isEmpty) {
      return Left<Failure, Success>(VerifyNameFailure(const EmptyNameException()));
    } else {
      return Right<Failure, Success>(VerifyNameViewState());
    }
  }
}

CompositeNameValidator

class CompositeNameValidator extends Validator<NewNameRequest> {

  final List<Validator> _listValidator;

  CompositeNameValidator(this._listValidator);

  @override
  Either<Failure, Success> validate(NewNameRequest value) {
    return _listValidator.isNotEmpty
      ? _listValidator.getValidatorNameViewState(value)
      : Right<Failure, Success>(VerifyNameViewState());
  }
}

VerifyNameInteractor

class VerifyNameInteractor {
  Either<Failure, Success> execute(String? newName, List<Validator> listValidator) {
    try {
      return CompositeNameValidator(listValidator).validate(NewNameRequest(newName));
    } catch (exception) {
      return Left<Failure, Success>(VerifyNameFailure(exception));
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working QA::Minor
Projects
None yet
Development

No branches or pull requests

3 participants