import { ValidationError } from "../../errors/validation-error";
import { MailRequest } from "./mail-request";
import { MailValidator } from "./validators/mail-validator";
import { RequestByUsernameValidator } from "./validators/request-by-username-validator";
/**
 * A request for sending e-mails specified users by username.
 */
export class MailRequestByUsername extends MailRequest {
    constructor() {
        super(...arguments);
        this.recipients = [];
    }
    validate() {
        const mailFailures = new MailValidator().validate(this);
        const usernamesFailures = new RequestByUsernameValidator().validate(this);
        if (mailFailures.length === 0 && usernamesFailures.length === 0) {
            return;
        }
        else {
            const failures = mailFailures.concat(usernamesFailures);
            throw new ValidationError("MailRequestByUsername is invalid", ...failures);
        }
    }
}
//# sourceMappingURL=mail-request-by-username.js.map