matcher/src/modules/ad/core/domain/candidate.entity.ts

21 lines
736 B
TypeScript

import { AggregateRoot, AggregateID } from '@mobicoop/ddd-library';
import { CandidateProps, CreateCandidateProps } from './candidate.types';
import { WayStepProps } from './value-objects/waystep.value-object';
export class CandidateEntity extends AggregateRoot<CandidateProps> {
protected readonly _id: AggregateID;
static create = (create: CreateCandidateProps): CandidateEntity => {
const props: CandidateProps = { ...create };
return new CandidateEntity({ id: create.id, props });
};
setCarpoolPath = (waySteps: WayStepProps[]): void => {
this.props.carpoolSteps = waySteps;
};
validate(): void {
// entity business rules validation to protect it's invariant before saving entity to a database
}
}