Sha256: 7932865d5cddecce57833b440cdc756c4ef18a4555e46bb5e8f1bb16c8fc6b55

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module BootstrapValidatorRails
  module Validators
    class Length < Validator

      def generate_options!
        @html_attributes ||= {}
        @js_options ||= {}

        return if unsupported?
        
        options = validator_options

        @html_attributes[:bv_stringlength] = 'true'
        @js_options['stringLength'] = {} 

        if options[:minimum]
          @html_attributes[:bv_stringlength_min] = @js_options['stringLength']['min'] = options[:minimum] 
        end

        if options[:maximum]
          @html_attributes[:bv_stringlength_max] = @js_options['stringLength']['max'] = options[:maximum] 
        end

        if options[:is]
          @html_attributes[:bv_stringlength_minimum] = options[:is] 
          @js_options['stringLength']['min'] = options[:is]
          @html_attributes[:bv_stringlength_maximum] = options[:is] 
          @js_options['stringLength']['max'] = options[:is]
          @html_attributes[:bv_stringlength_message] = @js_options['stringLength']['message'] = generate_message 
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bootstrap_validator_rails-1.1.0 lib/bootstrap_validator_rails/validators/length_validator.rb
bootstrap_validator_rails-1.0.0 lib/bootstrap_validator_rails/validators/length_validator.rb