Here’s an example from the Programming Elm book. It disables the form button for an empty string. It seems to work fine without the duplicate check for empty strings (it won’t post when pressing the button, or pressing Enter).
I’m wondering the same thing for the likes of:
- HTML5 fields with regex
- Number fields
- Telephone number
- and so on
If you were communicating to a server, I think conventional wisdom says to validate at server-side too. So perhaps this is important if you’re validating json to post.[1]
UPDATE (23rd July)
Just to answer my own question, it is indeed worthwhile to double check data on saving to the Model
, in the unlikely event that someone screws up your <button disabled>
with inspect element. It’s a shame HTML isn’t a bit more rigid in that manner.
How likely that is, I don’t know … but it’s a safe way to protect data entry. To be fair, they could probably just as easily screw up your javascript, too!
You might also want to see “What is the “Elm Way” to validate form fields?”. ↩︎