class Assert::Assertions::Url(PropertyType)
Overview
Validates a string is a properly formatted URL.
Optional Arguments
- protocols - The protocols considered to be valid.
- relative_protocol - If the protocol is optional.
- normalizer - Execute a Procto alter actual before checking its validity.
Example
class Example
  include Assert
  def initialize; end
  @[Assert::Url]
  property ipv6_url : String = "http://[::1]:80/"
  @[Assert::Url(relative_protocol: true)]
  property relative_url : String = "//example.fake/blog/"
  @[Assert::Url(protocols: %w(ftp file git))]
  property file_url : String = "file://127.0.0.1"
  @[Assert::Url(normalizer: ->(actual : String) { actual.strip })]
  property normalizer : String = "\x09\x09http://www.google.com"
end
Example.new.valid? # => trueDefined in:
assertions/url.crConstructors
Instance Method Summary
- 
        #default_message_template : String
        
          Returns the default #message_templateto use if no message is provided.
- 
        #message : String
        
          The message to display if selfis not valid.
- 
        #valid? : Bool
        
          Returns trueif a property satisfiesself, otherwisefalse.
Instance methods inherited from class Assert::Assertions::Assertion
  
  
    
      default_message_template : String
    default_message_template, 
    
  
    
      groups : Array(String)
    groups, 
    
  
    
      message : String
    message, 
    
  
    
      message_template : String
    message_template, 
    
  
    
      property_name : String
    property_name, 
    
  
    
      valid? : Bool
    valid?
    
  
    
  Constructor methods inherited from class Assert::Assertions::Assertion
  
  
    
      new(property_name : String, message : String | Nil = nil, groups : Array(String) | Nil = nil)
    new
    
  
    
  
    
    
    
  
    
    
    
  
Constructor Detail
        
        def self.new(property_name : String, actual : Union(String, Nil), protocols : Array(String) = ["http", "https"] of ::String, relative_protocol : Bool = false, normalizer : Proc(String, String) | Nil = nil, message : String | Nil = nil, groups : Array(String) | Nil = nil)
        #
      
      
      Instance Method Detail
        
        def default_message_template : String
        #
      
      
        Returns the default #message_template to use if no message is provided.
        
        def message : String
        #
      
      
        The message to display if self is not valid.
NOTE This method is defined automatically, and is just present for documentation purposes.