1
1
mirror of https://github.com/theoludwig/p61-project.git synced 2024-07-17 07:00:12 +02:00
p61-project/domain/entities/_Entity.ts

23 lines
439 B
TypeScript

import { z } from "zod"
export const EntitySchema = z.object({
id: z.string(),
})
export type EntityData = z.infer<typeof EntitySchema>
export abstract class Entity implements EntityData {
public readonly id: string
public constructor(options: EntityData) {
const { id } = options
this.id = id
}
public equals(entity: Entity): boolean {
return entity.id === this.id
}
public abstract toJSON(): EntityData
}