TF-585 Fix identity restrict BCC field
This commit is contained in:
@@ -5,6 +5,7 @@ abstract class VerifyNameException extends Equatable implements Exception {
|
||||
static const emptyName = 'The name cannot be empty!';
|
||||
static const duplicatedName = 'The name already exists!';
|
||||
static const nameContainSpecialCharacter = 'The name cannot contain special characters';
|
||||
static const emailAddressInvalid = 'The email address invalid';
|
||||
|
||||
final String? message;
|
||||
|
||||
@@ -28,6 +29,13 @@ class DuplicatedNameException extends VerifyNameException {
|
||||
class SpecialCharacterException extends VerifyNameException {
|
||||
const SpecialCharacterException() : super(VerifyNameException.nameContainSpecialCharacter);
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class EmailAddressInvalidException extends VerifyNameException {
|
||||
const EmailAddressInvalidException() : super(VerifyNameException.emailAddressInvalid);
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/exceptions/verify_name_exception.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/model/verification/new_name_request.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/model/verification/validator.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/state/verify_name_view_state.dart';
|
||||
|
||||
class EmailAddressValidator extends Validator<NewNameRequest> {
|
||||
|
||||
@override
|
||||
Either<Failure, Success> validate(NewNameRequest newNameRequest) {
|
||||
if (newNameRequest.value != null && GetUtils.isEmail(newNameRequest.value!)) {
|
||||
return Right<Failure, Success>(VerifyNameViewState());
|
||||
} else {
|
||||
return Left<Failure, Success>(VerifyNameFailure(const EmailAddressInvalidException()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,8 @@ extension ValicatorFailureExtension on VerifyNameFailure {
|
||||
String getMessageIdentity(BuildContext context) {
|
||||
if (exception is EmptyNameException) {
|
||||
return AppLocalizations.of(context).this_field_cannot_be_blank;
|
||||
} else if (exception is EmailAddressInvalidException) {
|
||||
return AppLocalizations.of(context).thisEmailAddressInvalid;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user