function ValidateCommonClient() {
    var erreur = [];

    if($('#commonNom').val().length < 5){
        erreur.push("Le nom fait moins de 5");

    }

    if(erreur.length > 0)
        return erreur;


    return true;
}

function ValidateInscriptionSmsService() {

    return true;
}

function ValidateTest() {

    return true;
}

var listChecks = [];

listChecks["ValidateCommonClient"] = ValidateCommonClient;
listChecks["ValidateInscriptionSmsService"] = ValidateInscriptionSmsService;
listChecks["ValidateTest"] = ValidateTest;

function addFunction(name, functionToAdd){
    listChecks[name] = functionToAdd;
}


function testAllElement() {
    var error = [];
    var divElementForm = $("#form_espace_client .block-form > div ");
    divElementForm.each(function (index) {
        var className = $(this).attr("data-functiontest");
        var functionTest = listChecks[className]();
        if(functionTest !== true){
            error = error.concat(functionTest);
        }
    });

    if(error.length > 0){
        alert(error);
    } else {
        $("#form_espace_client").submit()
    }
}

export {
    addFunction,
    testAllElement
};
