fase(9): auth module with casl rbac and session management
This commit is contained in:
18
dist/modules/auth/domain/value-objects/Email.js
vendored
Normal file
18
dist/modules/auth/domain/value-objects/Email.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Email = void 0;
|
||||
const ValueObject_1 = require("../../../../shared/domain/ValueObject");
|
||||
class Email extends ValueObject_1.ValueObject {
|
||||
static create(value) {
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (!Email.EMAIL_REGEX.test(normalized)) {
|
||||
throw new Error(`Invalid email address: ${value}`);
|
||||
}
|
||||
return new Email({ value: normalized });
|
||||
}
|
||||
get value() {
|
||||
return this.props.value;
|
||||
}
|
||||
}
|
||||
exports.Email = Email;
|
||||
Email.EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
Reference in New Issue
Block a user