Sha256: b6ee583324460caceca43e7119d0e3fe42536bae1877a14b74cd0f8022f2212c
Contents?: true
Size: 893 Bytes
Versions: 3
Compression:
Stored size: 893 Bytes
Contents
# frozen_string_literal: true module SimpleForm module Components # Needs to be enabled in order to do automatic lookups. module Maxlength def maxlength(wrapper_options = nil) input_html_options[:maxlength] ||= maximum_length_from_validation || limit nil end private def maximum_length_from_validation maxlength = options[:maxlength] if maxlength.is_a?(String) || maxlength.is_a?(Integer) maxlength else length_validator = find_length_validator maximum_length_value_from(length_validator) end end def find_length_validator find_validator(:length) end def maximum_length_value_from(length_validator) if length_validator length_validator.options[:is] || length_validator.options[:maximum] end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
simple_form-5.3.0 | lib/simple_form/components/maxlength.rb |
simple_form-5.2.0 | lib/simple_form/components/maxlength.rb |
simple_form-5.1.0 | lib/simple_form/components/maxlength.rb |