williamgueiros / Brcpfcnpj

Validação,Formatação e Gerador Cpf/Cnpj em Elixir
MIT License
69 stars 17 forks source link

Changeset validation errors problem #7

Closed mauricioszabo closed 5 years ago

mauricioszabo commented 6 years ago

When adding validation errors on changeset functions, things are being added incorrectly: for example, this is how "default" errors in Ecto are being added:

errors: [name: {"can't be blank", [validation: :required]}

And this is how BrCNPJ are being added:

errors: [contract: "Document format invalid",

This means that FallbackController can't parse correctly these errors, and we're getting a run-time exception:

     ** (FunctionClauseError) no function clause matching in AppWeb.ErrorHelpers.translate_error/1

     The following arguments were given to AppWeb.ErrorHelpers.translate_error/1:

         # 1
         "Invalid Cnpj"

     Attempted function clauses (showing 1 out of 1):

         def translate_error({msg, opts})
williamgueiros commented 6 years ago

@tiagoengel do you think, is possible to help us, with that ?

mauricioszabo commented 6 years ago

Yep, I can. I'll submit a PR as soon as I can.

williamgueiros commented 6 years ago

Yes , tanks for you help

williamgueiros commented 6 years ago

And go ahead

tiagoengel commented 6 years ago

if I'm not mistaken this new error format is for ecto 2.0 onwards so it may be a good idea to update the lib's main version and indicate somewhere that the latest version is only compatible with the newest ecto version. Otherwise it may break old code using this lib

williamgueiros commented 6 years ago

create major release 0.1.0 to 0.2.0 and add readme Information.

williamgueiros commented 5 years ago

close that, in favor of #17