Add format validation to link.rb
This commit is contained in:
parent
00010867a4
commit
68e12fd737
|
@ -2,10 +2,8 @@ class Link < Item
|
||||||
|
|
||||||
field :url, localize: true
|
field :url, localize: true
|
||||||
|
|
||||||
validates :url, at_least_one: true
|
validates :url, at_least_one: true, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|localhost(:[0-9]{1,5})?(\/.*)?/i
|
||||||
|
|
||||||
# validates :url, :presence => true, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|localhost(:[0-9]{1,5})?(\/.*)?/i
|
|
||||||
|
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
|
|
||||||
def link
|
def link
|
||||||
|
|
Loading…
Reference in New Issue