Skip to content

Instantly share code, notes, and snippets.

@brunojabs
Last active August 29, 2015 13:57
Show Gist options
  • Save brunojabs/9787065 to your computer and use it in GitHub Desktop.
Save brunojabs/9787065 to your computer and use it in GitHub Desktop.
Rails validations to email and telephone number formats
validates :zipcode, format: { with: /[0-9]{5}-[0-9]{3}/ }
validates :phone, format: { with: /\(?[0-9]{2}\)? ?[0-9]{4,5}-?[0-9]{4}/ }
validates :email, format: { with: /\A.+@.+\..+\z/ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment