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

export interface ICreateDealer_Request_DTO {
  id: string;
  name: string;
  lang_code: string;
}

export function ensureCreateDealer_Request_DTOIsValid(dealerDTO: ICreateDealer_Request_DTO) {
  const schema = Joi.object({
    id: Joi.string(),
    name: Joi.string(),
  }).unknown(true);

  const result = RuleValidator.validate<ICreateDealer_Request_DTO>(schema, dealerDTO);

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

  return Result.ok(true);
}
