import Joi from "joi";
import { Result, RuleValidator } from "../../../common";

export interface ISendIncidence_Request_DTO {
  incidence: string;
}

export function ensureSendIncidence_Request_DTOIsValid(SupportDTO: ISendIncidence_Request_DTO) {
  const schema = Joi.object({
    incidence: Joi.string().min(10).max(1000).required(),
  });

  const result = RuleValidator.validate<ISendIncidence_Request_DTO>(schema, SupportDTO);

  if (result.isFailure) {
    return Result.fail(result.error);
  }

  return Result.ok(result.object);
}
