country-regions / country-region-selector

Dynamic country and region dropdowns for your forms.
http://country-regions.github.io/country-region-selector/
MIT License
255 stars 115 forks source link

Validating input #34

Open tremby opened 8 years ago

tremby commented 8 years ago

Given that this is being used on the client side and then data sent to the server, once on the server side, can I use this module in Node to validate the input data? How would I go about doing that?

ellenhutchings commented 8 years ago

Since the input is a drop down unless you allow users to input the data, then there is no way to know it's correctness without looking and checking as human. To check the accuracy using the data the options come from would only reinforce that the data comes from this list. which seems redundant. The list is supposed to use ISO3166-2 codes so you could maybe do something with that?

tremby commented 8 years ago

I was more thinking along the lines of if the package were to provide a validate function which takes a country and region as selected from the dropdown it provides, and returns true or false depending whether those values make sense given the data in the package.