[katello-devel] Katello Url Format Validator

Adam Price adprice at redhat.com
Fri Jul 1 18:15:51 UTC 2011


I came up with a little validator for checking URLs in the provider, 
then decided to make it a little more generic so that other things can 
use it as well.

Right now the only thing using it is the Provider model, but hopefully 
we can get it hooked up to Repositories also.

|validates :repository_url, :katello_url_format => {:protocol => 
["https"]}, :allow_nil => false, :if => :rh_repo?|

The line above is what is in Provider.rb. KatelloUrlFormatValidator 
takes an option specifying a list of protocols you want it to accept 
("https", "http", "ftp", "ssh", or whatever...) and it builds the 
regular expression. The regular expression accepts port numbers, 
subdomains, file paths after the domain, and also parameters.

Wanted to let you know so that hopefully it will get used elsewhere. Thanks.

-- 
Adam Price

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/katello-devel/attachments/20110701/83b408fc/attachment.htm>


More information about the katello-devel mailing list