Sha256: b4cdfe957310367166b14cc6aedac2cb11a095f7d1ce0118cf5f8ec4f6eeecff

Contents?: true

Size: 261 Bytes

Versions: 6

Compression:

Stored size: 261 Bytes

Contents

class HtmlValidator < ActiveModel::EachValidator
  def validate_each(object, attribute, value)
    unless value =~ /^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/
      object.errors[attribute] << (options[:message] || "is not formatted properly")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
drexed-validators-0.0.13 app/validators/html_validator.rb
drexed-validators-0.0.12 app/validators/html_validator.rb
drexed-validators-0.0.11 app/validators/html_validator.rb
drexed-validators-0.0.10 app/validators/html_validator.rb
drexed-validators-0.0.9 app/validators/html_validator.rb
drexed-validators-0.0.7 app/validators/html_validator.rb