feat: added validation method to entity (no example yet)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user