Files
goodgo-platform/apps/api/src/modules/auth/domain/value-objects/email.vo.ts
Ho Ngoc Hai 36e0f49e9e feat(auth): add handler specs and improve auth infrastructure
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>
2026-04-09 09:42:16 +07:00

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 }));
}
}