How to validate country and city input fields properly?

Hello everybody!

Currently I am working on user sign up feature and I am struggling a little finding the best way to validate that country input field only contains valid values and the same for city input field.

Any ideas about how I can get it?

Thanks in advance!!

1 Like

Either cldr or libpostal …

Once you have the reference data set/source, building the validation on a field or using a select (like live_select) should be pretty straightforward …
Hope this helps.

4 Likes

ex_cldr_html provides a CLDR-based territory select dropdown (dead view version). It might give you some ideas for a live view version (CLDR-based components is “on the list” with no committed timeframe).

5 Likes

Thanks!!

BTW> if you go for the liveview version, don’t forget to use phx-debounce else you will be hitting your database for every keystroke.