Cast decimals with comma separator in Ecto

Hi there,

I’d like to support numbers with a comma as the decimal separator. Say 12,75 instead of 12.75.

However as soon as I type in the comma in a Ecto field of type decimal, it returns an error.

How could I change that?

Are you referring to the number on a browser input field? You should be able to set the lang attribute on the input, form, or html element to influence the localisation of the number input presented to the user, while the browser should still send back a dot-decimal as expected.

See Browser support for <input type="number"> with different decimal marks for reference.