Class: Rails::Angulate::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/angulate/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



14
15
16
17
18
# File 'lib/rails/angulate/configuration.rb', line 14

def initialize
  self.validate_on = { submit_attempt: :or, blur: nil }
  self.validate_show_condition = "%{field}.$invalid && (%{validate_on})"
  self.default_error_classes = []
end

Instance Attribute Details

#default_error_classesObject

Set on what conditions do you want the validation messages to show

Possible values: blur: only once the field has been visited dirty: only if the field is dirty submit_attempt: only once the user has submitted the form



12
13
14
# File 'lib/rails/angulate/configuration.rb', line 12

def default_error_classes
  @default_error_classes
end

#validate_onObject

Set on what conditions do you want the validation messages to show

Possible values: blur: only once the field has been visited dirty: only if the field is dirty submit_attempt: only once the user has submitted the form



12
13
14
# File 'lib/rails/angulate/configuration.rb', line 12

def validate_on
  @validate_on
end

#validate_show_conditionObject

Set on what conditions do you want the validation messages to show

Possible values: blur: only once the field has been visited dirty: only if the field is dirty submit_attempt: only once the user has submitted the form



12
13
14
# File 'lib/rails/angulate/configuration.rb', line 12

def validate_show_condition
  @validate_show_condition
end

#validator_mappingsObject



20
21
22
23
24
25
26
# File 'lib/rails/angulate/configuration.rb', line 20

def validator_mappings
  @validator_mappings ||= {
    presence: 'required',
    format: 'pattern',
    length: 'maxlength'
  }
end

Instance Method Details

#add_mapper(name, mapper_class) ⇒ Object



28
29
30
# File 'lib/rails/angulate/configuration.rb', line 28

def add_mapper(name, mapper_class)
  Rails::Angulate::Mappers.register_mapper(name, mapper_class)
end