Sha256: 766ffb11c8e110dcc39d1443f356cf41fd9cd130a4ca2eeec9c19700061cb640

Contents?: true

Size: 575 Bytes

Versions: 3

Compression:

Stored size: 575 Bytes

Contents

module SimpleForm
  module Helpers
    # Helper methods for maxlength.
    module Maxlength #:nodoc:

      private

      def add_maxlength!
        input_html_options[:maxlength] ||= maximum_length_from_validation || limit if SimpleForm.html5
      end

      def maximum_length_from_validation
        return unless has_validators?

        length_validator = find_length_validator or return
        length_validator.options[:maximum]
      end

      def find_length_validator
        find_validator(ActiveModel::Validations::LengthValidator)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple_form-1.5.2 lib/simple_form/helpers/maxlength.rb
simple_form-1.5.1 lib/simple_form/helpers/maxlength.rb
simple_form-1.5.0 lib/simple_form/helpers/maxlength.rb