mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
set bold
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { ZodSchema, ZodType } from 'zod';
|
||||
|
||||
|
||||
|
||||
// export interface IEntity {
|
||||
// id: string;
|
||||
|
||||
// createdAt: Date;
|
||||
|
||||
// updatedAt: Date;
|
||||
|
||||
// deletedAt?: Date;
|
||||
// }
|
||||
|
||||
export const BaseEntity = <T>(schema: ZodSchema) => {
|
||||
abstract class Entity {
|
||||
readonly id: string;
|
||||
|
||||
readonly createdAt: Date;
|
||||
|
||||
readonly updatedAt: Date;
|
||||
|
||||
deletedAt?: Date;
|
||||
|
||||
static nameOf = (name: keyof T) => name;
|
||||
|
||||
validate<T>(entity: T): ZodType {
|
||||
return schema.parse(entity);
|
||||
}
|
||||
}
|
||||
|
||||
return Entity;
|
||||
};
|
||||
Reference in New Issue
Block a user