import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface, } from "class-validator"; @ValidatorConstraint({ name: "objectionPartHasContent", async: false }) export class ObjectionPartHasContentConstraint implements ValidatorConstraintInterface { validate(_value: unknown, args: ValidationArguments): boolean { const o = args.object as { reason?: string; partPrice?: string; partSalary?: string; }; const hasReason = typeof o.reason === "string" && o.reason.trim().length >= 3; const hasPrice = o.partPrice != null && String(o.partPrice).trim() !== ""; const hasSalary = o.partSalary != null && String(o.partSalary).trim() !== ""; return hasReason || hasPrice || hasSalary; } defaultMessage(): string { return "Each objection line needs a reason (min 3 characters) and/or proposed partPrice / partSalary."; } }