Class: BootstrapValidatorRails::Validators::Numericality
- Inherits:
-
Object
- Object
- BootstrapValidatorRails::Validators::Numericality
- Defined in:
- lib/bootstrap_validator_rails/validators/numericality_validator.rb
Instance Method Summary collapse
- #generate_data ⇒ Object
- #generate_message ⇒ Object
- #generate_options ⇒ Object
-
#initialize(record, method, validator) ⇒ Numericality
constructor
A new instance of Numericality.
Constructor Details
#initialize(record, method, validator) ⇒ Numericality
Returns a new instance of Numericality.
4 5 6 |
# File 'lib/bootstrap_validator_rails/validators/numericality_validator.rb', line 4 def initialize(record, method, validator) @record, @method, @validator = record, method, validator end |
Instance Method Details
#generate_data ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/bootstrap_validator_rails/validators/numericality_validator.rb', line 8 def generate_data data = { :bv_numeric_separator => '', :bv_numeric_separator_message => } data.merge() end |
#generate_message ⇒ Object
17 18 19 |
# File 'lib/bootstrap_validator_rails/validators/numericality_validator.rb', line 17 def @record.errors.(@method, :presence, {default: 'should be a number'}) end |
#generate_options ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bootstrap_validator_rails/validators/numericality_validator.rb', line 21 def = @validator. data = {} if [:greater_than].present? data[:bv_greaterthan_inclusive] = 'false' data[:bv_greaterthan_value] = [:greater_than] end if [:greater_than_or_equal_to].present? data[:bv_greaterthan_inclusive] = 'true' data[:bv_greaterthan_value] = [:greater_than_or_equal_to] end if [:less_than].present? data[:bv_lessthan_inclusive] = 'false' data[:bv_lessthan_value] = [:less_than] end if [:less_than_or_equal_to].present? data[:bv_lessthan_inclusive] = 'true' data[:bv_lessthan_value] = [:less_than_or_equal_to] end data end |