Class: Rails::Angulate::Mappers::FormatValidatorMapper

Inherits:
BaseMapper
  • Object
show all
Defined in:
lib/rails/angulate/mappers/format_validator_mapper.rb

Instance Attribute Summary

Attributes inherited from BaseMapper

#attribute, #model, #validator

Instance Method Summary collapse

Methods inherited from BaseMapper

#error_messages, #full_message, inherited, #initialize

Constructor Details

This class inherits a constructor from Rails::Angulate::Mappers::BaseMapper

Instance Method Details

#ng_attributesObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rails/angulate/mappers/format_validator_mapper.rb', line 5

def ng_attributes
  {}.tap do |attrs|
    if pattern = validator_options[:javascript_format]
      attrs["ng-pattern"] = pattern
    elsif pattern = validator_options[:with]
      attrs["ng-pattern"] = javascriptify_pattern(pattern.source)
    elsif validator_options[:without]
      ActiveSupport::Deprecation.warn(<<-TEXT.strip)
      Angulate does not support validates_format validation using the without option.
      Use the 'with' and/or 'javascript_format' options instead.
      TEXT
    end
  end
end