Sha256: 518b76dd762426a613fe4f8daadbf6c0621e8193a6f8a353102dddeceb8e2ea6
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
module SimpleFormWithClientValidation module Components # Needs to be enabled in order to do automatic lookups. module Minlength def minlength input_html_options[:'minlength'] ||= minimum_length_from_validation || 0 nil end private def minimum_length_from_validation minlength = options[:minlength] if minlength.is_a?(String) || minlength.is_a?(Integer) minlength else length_validator = find_length_validator if length_validator && !has_tokenizer?(length_validator) length_validator.options[:is] || length_validator.options[:minimum] end end end def find_length_validator find_validator(ActiveModel::Validations::LengthValidator) end def has_tokenizer?(length_validator) tokenizer = length_validator.options[:tokenizer] # TODO: Remove this check when we drop Rails 3.0 support if ActiveModel::Validations::LengthValidator.const_defined?(:DEFAULT_TOKENIZER) tokenizer && tokenizer != ActiveModel::Validations::LengthValidator::DEFAULT_TOKENIZER else tokenizer end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems