feat: added validation method to entity (no example yet)

This commit is contained in:
user
2020-11-30 17:14:12 +01:00
parent d9ca0a1121
commit 886283f00e

View File

@@ -16,6 +16,7 @@ export interface UpdateUserAddressProps {
export class UserEntity extends Entity<UserProps> {
constructor(props: UserProps) {
super(props);
UserEntity.validate(props); // validating at construction
this._email = props.email;
this._address = props.address;
}
@@ -41,4 +42,9 @@ export class UserEntity extends Entity<UserProps> {
someBusinessLogic(): void {
// TODO: add example business logic
}
static validate(props: UserProps): void {
// TODO: example
// entity business rules validation to protect it's invariant
}
}