Skip to content

Instantly share code, notes, and snippets.

@descovi
Created February 20, 2013 07:54
Show Gist options
  • Save descovi/4993768 to your computer and use it in GitHub Desktop.
Save descovi/4993768 to your computer and use it in GitHub Desktop.
Validate a url with http or without / Validare una url con http sia senza http
# RegEx: is from http://stackoverflow.com/a/13311941/632478
# Rubular: http://rubular.com/r/cdkLxAkTbk
validates :url, format: { with: /^(http|https):\/\/|[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}(:[0-9]{1,5})?(\/.*)?$/ix }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment