.
This commit is contained in:
parent
bcfc517a26
commit
7cf1e713c9
@ -10,9 +10,11 @@ import Joi from "joi";
|
||||
|
||||
export enum QUOTE_STATUS {
|
||||
DRAFT = "draft",
|
||||
EMITTED = "emitted",
|
||||
SENT = "sent",
|
||||
READY = "ready",
|
||||
DELIVERED = "delivered",
|
||||
ACCEPTED = "accepted",
|
||||
REJECTED = "rejected",
|
||||
ARCHIVED = "archived",
|
||||
}
|
||||
export interface IQuoteStatusOptions extends IValueObjectOptions {}
|
||||
|
||||
@ -21,7 +23,14 @@ export class QuoteStatus extends ValueObject<string> {
|
||||
|
||||
protected static validate(value: string, options: IValueObjectOptions) {
|
||||
const rule = Joi.string()
|
||||
.valid(QUOTE_STATUS.DRAFT, QUOTE_STATUS.EMITTED, QUOTE_STATUS.SENT, QUOTE_STATUS.REJECTED)
|
||||
.valid(
|
||||
QUOTE_STATUS.DRAFT,
|
||||
QUOTE_STATUS.READY,
|
||||
QUOTE_STATUS.DELIVERED,
|
||||
QUOTE_STATUS.ACCEPTED,
|
||||
QUOTE_STATUS.REJECTED,
|
||||
QUOTE_STATUS.DRAFT
|
||||
)
|
||||
.label(options.label ? options.label : "status");
|
||||
|
||||
return RuleValidator.validate<string>(rule, value);
|
||||
@ -35,18 +44,26 @@ export class QuoteStatus extends ValueObject<string> {
|
||||
return new QuoteStatus(QUOTE_STATUS.DRAFT);
|
||||
}
|
||||
|
||||
public static createEmitted(): QuoteStatus {
|
||||
return new QuoteStatus(QUOTE_STATUS.EMITTED);
|
||||
public static createReady(): QuoteStatus {
|
||||
return new QuoteStatus(QUOTE_STATUS.READY);
|
||||
}
|
||||
|
||||
public static createSent(): QuoteStatus {
|
||||
return new QuoteStatus(QUOTE_STATUS.SENT);
|
||||
public static createDelivered(): QuoteStatus {
|
||||
return new QuoteStatus(QUOTE_STATUS.DELIVERED);
|
||||
}
|
||||
|
||||
public static createAccepted(): QuoteStatus {
|
||||
return new QuoteStatus(QUOTE_STATUS.ACCEPTED);
|
||||
}
|
||||
|
||||
public static createRejected(): QuoteStatus {
|
||||
return new QuoteStatus(QUOTE_STATUS.REJECTED);
|
||||
}
|
||||
|
||||
public static createArchived(): QuoteStatus {
|
||||
return new QuoteStatus(QUOTE_STATUS.ARCHIVED);
|
||||
}
|
||||
|
||||
public static create(status: string, options: IQuoteStatusOptions = {}) {
|
||||
const _options = {
|
||||
label: "status",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user