22 lines
604 B
TypeScript
22 lines
604 B
TypeScript
|
|
import { CompositeSpecification, UniqueID } from "@repo/rdx-ddd";
|
||
|
|
import { CustomerService } from "../../domain";
|
||
|
|
|
||
|
|
export class CustomerNotExistsInCompanySpecification extends CompositeSpecification<UniqueID> {
|
||
|
|
constructor(
|
||
|
|
private readonly service: CustomerService,
|
||
|
|
private readonly companyId: UniqueID,
|
||
|
|
private readonly transaction?: any
|
||
|
|
) {
|
||
|
|
super();
|
||
|
|
}
|
||
|
|
|
||
|
|
public async isSatisfiedBy(customerId: UniqueID): Promise<boolean> {
|
||
|
|
const exists = await this.service.existsByIdInCompany(
|
||
|
|
customerId,
|
||
|
|
this.companyId,
|
||
|
|
this.transaction
|
||
|
|
);
|
||
|
|
return !exists;
|
||
|
|
}
|
||
|
|
}
|