Class: Rails::Angulate::Mappers::LengthValidatorMapper
- Inherits:
-
BaseMapper
- Object
- BaseMapper
- Rails::Angulate::Mappers::LengthValidatorMapper
- Defined in:
- lib/rails/angulate/mappers/length_validator_mapper.rb
Constant Summary collapse
- OPTION_MAP =
{ is: :islength, minimum: :minlength, maximum: :maxlength }.freeze
Instance Attribute Summary
Attributes inherited from BaseMapper
#attribute, #model, #validator
Instance Method Summary collapse
Methods inherited from BaseMapper
#full_message, inherited, #initialize
Constructor Details
This class inherits a constructor from Rails::Angulate::Mappers::BaseMapper
Instance Method Details
#error_messages ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rails/angulate/mappers/length_validator_mapper.rb', line 16 def = {} = [:message] with_i18n do |locale| validator.class::MESSAGES.each do |key, msg| if .nil? next unless [key] count = [key] = locale.t( :"messages.#{msg}", model: model.class.name.humanize, attribute: attribute.to_s.humanize, count: count ) [OPTION_MAP[key]] = () else [OPTION_MAP[key]] = end end end end |
#ng_attributes ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/rails/angulate/mappers/length_validator_mapper.rb', line 7 def ng_attributes opts = {}.tap do |attrs| .each do |key, value| attrs["ng-#{OPTION_MAP[key]}"] = opts[key] if opts[key].present? end end end |