Add unit tests for get-profile, get-agent-by-user-id, and verify-kyc handlers. Improve OAuth service, local strategy, and repository implementations with proper ConfigService injection and error handling. Co-Authored-By: Paperclip <noreply@paperclip.ing>
22 lines
554 B
TypeScript
22 lines
554 B
TypeScript
import { Result, ValueObject } from '@modules/shared';
|
|
|
|
interface EmailProps {
|
|
value: string;
|
|
}
|
|
|
|
export class Email extends ValueObject<EmailProps> {
|
|
private static readonly EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
|
|
get value(): string {
|
|
return this.props.value;
|
|
}
|
|
|
|
static create(email: string): Result<Email, string> {
|
|
const normalized = email.trim().toLowerCase();
|
|
if (!this.EMAIL_REGEX.test(normalized)) {
|
|
return Result.err('Email không hợp lệ');
|
|
}
|
|
return Result.ok(new Email({ value: normalized }));
|
|
}
|
|
}
|