class Formulary::HtmlForm::Fields::Input
Public Class Methods
compatible_with?(element)
click to toggle source
# File lib/formulary/html_form/fields/input.rb, line 3 def self.compatible_with?(element) element.name == "input" && element.attributes["type"].value == compatible_type end
supports_required?()
click to toggle source
# File lib/formulary/html_form/fields/input.rb, line 8 def self.supports_required? true end
Public Instance Methods
error()
click to toggle source
Calls superclass method
Formulary::HtmlForm::Fields::Field#error
# File lib/formulary/html_form/fields/input.rb, line 16 def error return super if super.present? return "'#{label}' does not match the expected format" unless pattern_correct? end
valid?()
click to toggle source
Calls superclass method
Formulary::HtmlForm::Fields::Field#valid?
# File lib/formulary/html_form/fields/input.rb, line 12 def valid? super && pattern_correct? end
Protected Instance Methods
pattern()
click to toggle source
# File lib/formulary/html_form/fields/input.rb, line 28 def pattern @element.attributes["pattern"].try(:value) end
pattern_correct?()
click to toggle source
# File lib/formulary/html_form/fields/input.rb, line 23 def pattern_correct? return true if pattern.blank? || @value.blank? @value.match(Regexp.new(pattern)) end