Created
September 15, 2016 17:34
-
-
Save bootcoder/f014bb6504c86d2a43ad39d8d49027e0 to your computer and use it in GitHub Desktop.
notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phone numbers -- format? | |
string == 3525678908 | |
string == (352)5678908 | |
string == (352)567-8908 | |
string == 352.567.8908 | |
string == 3525678908 | |
error handling | |
areacode 352 | |
prefix 870 | |
suffic 6756 | |
<form> | |
<input type="text" name="user[phone][areacode]"> | |
<input type="text" name="user[phone][prefix]"> | |
<input type="text" name="user[phone][suffix]"> | |
</form> | |
<form> | |
<input type="text" name="user[phone]"> | |
</form> | |
MODEL | |
def sanitize_phone_input(input) | |
<!-- use regex here to remove all chacters which are not digits --> | |
self.phone_numebr = reged_input | |
end | |
post '/users' do | |
end | |
MODEL before validates run callback concat phone to make a single string from the 3 inputs | |
then run a model validation to check the format of said string (10 digits also only digits) | |
additionally though I would set up some javascript to validate the input on the frontend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment