Sha256: 2e8fa084e6413b69c4d07dc82acff4a31eb51e7391e66161eb3e4998b79fed7e
Contents?: true
Size: 422 Bytes
Versions: 1
Compression:
Stored size: 422 Bytes
Contents
class HostNameValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) record.errors[attribute] << I18n.t("errors.messages.invalid") unless HostName.new(value).valid? end end class HostName def initialize(host_name) @host_name = host_name end def valid? return true if @host_name.blank? @host_name =~ /^[a-z][a-z0-9-]+$/ end def host_name @host_name end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
validates_host-0.1.0 | lib/validates_host/host_name_validator.rb |