const HttpException = require('../../../utils/HttpException.js');

exports.validateStoreVendorRequest = (body) => {
    const { name, name_pt, strengths, weaknesses, website } = body;

    const errors = {};

    if (!name || name.trim() === '') {
        errors.name = ['Vendor name is required'];
    }
    if (!name_pt || name_pt.trim() === '') {
        errors.name_pt = ['Vendor name pt is required'];
    }
    if (!strengths || strengths.trim() === '') {
        errors.strengths = ['Vendor strengths is required'];
    }
    if (!weaknesses || weaknesses.trim() === '') {
        errors.weaknesses = ['Vendor weaknesses is required'];
    }
    if (!website || website.trim() === '') {
        errors.website = ['Vendor website is required'];
    }

    if (Object.keys(errors).length > 0) {
        throw new HttpException(errors, 422);
    }

    return {
        name: name.trim(),
        name_pt: name_pt.trim(),
        strengths: strengths.trim(),
        weaknesses: weaknesses.trim(),
        website: website.trim(),
    };
};