2
I have some validations of mandatory fields in my application and today I do this way:
verificarObrigatorios(): boolean{
    if(!this.pessoa.nome)
    {
        this.toastr.showMessage("Nome Obrigatório")
        return false;
    }
    if(!this.pessoa.cpf)
    {
        this.toastr.showMessage("CPF Obrigatório")
        return false;
    }
    if(!this.pessoa.dataNascimento)
    {
        this.toastr.showMessage("Data de Nascimento Obrigatório")
        return false;
    }
    //...
    return true;
}
I was giving a study on this issue, to decrease the amount of if/else but I couldn’t fit into my scenario. How can I reduce them?
https://codesandbox.io/s/goofy-ptolemy-dl81e?file=/src/index.js, have a look!
– Marconi