const signUpError = require("../../../utils/customErrors/signUpError");
import {signUpSchema} from "../../../utils/schemasYup/signUpSchema";
import {updateUsersDataWithoutPasswordSchema} from "../../../utils/schemasYup/updateUsersDataWithoutPasswordSchema";

module.exports = async (req, res, next) => {
    const {password} = req.body;

    if( password ) {
        if( await signUpSchema.isValid(req.body) ) {
            next();
        }else {
            next(new signUpError());
        }
    }else {
        if( await updateUsersDataWithoutPasswordSchema.isValid(req.body) ) {
            next();
        }else {
            next(new signUpError());
        }
    }



};