Sha256: 046b0a41ed5a5940cdb48dbec4d3b7258a3f0d33b8f1ced44d125951812167c0

Contents?: true

Size: 392 Bytes

Versions: 1

Compression:

Stored size: 392 Bytes

Contents

class Typero::UrlType < Typero::Type
  def set
    @value = 'http://%s' % @value unless @value.include?('://')
  end

  def validate
    raise TypeError, error_for(:not_starting_error) unless @value =~ /^https?:\/\/./
  end

  def not_starting_error
    'URL is not starting with http'
  end

  def db_field
    opts = {}
    opts[:null] = false if @opts[:req]
    [:string, opts]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typero-0.5.2 ./lib/typero/type/url.rb