Sha256: aeb20af2193de7f60b4ee8bd82006657379a8f82d588edf5b46cc3491c3c4d11

Contents?: true

Size: 740 Bytes

Versions: 1

Compression:

Stored size: 740 Bytes

Contents

module FormGroups
  mattr_accessor(:field_class) { 'field' }
  mattr_accessor(:field_error_class) { 'field-error' }
  mattr_accessor(:map_validators) { true }

  mattr_reader :validator_mapping do
    mappings = {}

    mappings['ActiveModel::Validations::LengthValidator'] = Proc.new do |validator, result|
      result['minlength'] = validator.options[:minimum] if validator.options[:minimum]
      result['maxlength'] = validator.options[:maximum] if validator.options[:maximum]
    end

    mappings['ActiveModel::Validations::PresenceValidator'] = Proc.new do |validator, result|
      result['required'] = 'true'
      result['aria-required'] = 'true'
    end

    mappings
  end

  def self.configure &block
    yield self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
formgroups-rails-0.0.3 lib/form_groups/configuration.rb