Validation for URL/Domain using Regex? (Rails)

后端 未结 13 1772
野的像风
野的像风 2020-11-29 21:10

I am trying to create a validation that checks to make sure a domain/url is valid for example \"test.com\"

def valid_domain_name?
  domain_name = domain.spli         


        
13条回答
  •  一生所求
    2020-11-29 21:39

    Another way to do URL validation in Rails is

    validates :web_address, :format => { :with => URI::regexp(%w(http https)), :message => "Valid URL required"}
    

提交回复
热议问题