Open dab246 opened 2 months ago
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));
}
}
}
Env:
2.6.5
stg.lin-saas.com
Chrome, Edge(Macbook)
Steps to reproduce
space
in name input fieldDone
icon to creates a group chatExpectation
Evidence
https://github.com/user-attachments/assets/d613ae51-8941-4a51-946a-26049d053eed