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

exports.validateLoginRequest = (body) => {
    const { username, password } = body;
    const errors = {};

    if (!username || username.trim() === '') {
        errors.username = ['Username is required'];
    }

    if (!password || password.trim() === '') {
        errors.password = ['Password is required'];
    }

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

    return {
        username: username.trim(),
        password: password.trim()
    };
};
