🧤K
Size: a a a
🧤K
S
🧤K
S
S
🧤K
S
🧤K
G
L
export class User {
readonly email: string;
readonly firstName: string;
readonly lastName: string;
private constructor(props: UserConstructorArgs) {
this.email = props.email;
this.firstName = props.firstName;
this.lastName = props.lastName;
}
static build({
email,
firstName,
lastName,
}: {
email: string;
firstName: string;
lastName: string;
}): Either<Failure<UserError.InvalidCreationArguments>, User> {
if ([email, firstName, lastName].some(field => field.length === 0)) {
return left(invalidCreationArgumentsError());
}
return right(new User({ email, firstName, lastName }));
}
}
S
export class User {
readonly email: string;
readonly firstName: string;
readonly lastName: string;
private constructor(props: UserConstructorArgs) {
this.email = props.email;
this.firstName = props.firstName;
this.lastName = props.lastName;
}
static build({
email,
firstName,
lastName,
}: {
email: string;
firstName: string;
lastName: string;
}): Either<Failure<UserError.InvalidCreationArguments>, User> {
if ([email, firstName, lastName].some(field => field.length === 0)) {
return left(invalidCreationArgumentsError());
}
return right(new User({ email, firstName, lastName }));
}
}
S
S
S
L
🧤K
🧤K
🧤K