File

apps/recallassess/recallassess-api/src/api/admin/company/dto/company-next-billing-date.dto.ts

Index

Properties

Properties

next_billing_date
Type : string
Decorators :
@Transform( => )
@IsString()
@Matches(/^\d{4}-\d{2}-\d{2}$/, {message: 'next_billing_date must be in YYYY-MM-DD format'})
import { Transform } from "class-transformer";
import { IsString, Matches } from "class-validator";

export class CompanyNextBillingDateDto {
  @Transform(({ value }) => {
    if (value instanceof Date && !Number.isNaN(value.getTime())) {
      return value.toISOString().slice(0, 10);
    }
    if (typeof value === "string") {
      const v = value.trim();
      if (v.includes("T")) {
        const parsed = new Date(v);
        if (!Number.isNaN(parsed.getTime())) {
          return parsed.toISOString().slice(0, 10);
        }
      }
      return v;
    }
    return value;
  })
  @IsString()
  @Matches(/^\d{4}-\d{2}-\d{2}$/, {
    message: "next_billing_date must be in YYYY-MM-DD format",
  })
  next_billing_date!: string;
}

results matching ""

    No results matching ""