Class: Bureaucrat::Fields::FloatField
- Inherits:
-
IntegerField
- Object
- Field
- IntegerField
- Bureaucrat::Fields::FloatField
- Defined in:
- lib/bureaucrat/fields.rb
Instance Attribute Summary
Attributes inherited from Field
#error_messages, #help_text, #hidden_widget, #initial, #label, #required, #show_hidden_initial, #validators, #widget
Instance Method Summary collapse
Methods inherited from IntegerField
Methods inherited from Field
#bound_data, #clean, #default_hidden_widget, #default_validators, #default_widget, #initialize, #initialize_copy, #populate_object, #prepare_value, #run_validators, #validate, #widget_attrs
Constructor Details
This class inherits a constructor from Bureaucrat::Fields::IntegerField
Instance Method Details
#default_error_messages ⇒ Object
255 256 257 |
# File 'lib/bureaucrat/fields.rb', line 255 def super.merge(invalid: 'Enter a number.') end |
#to_object(value) ⇒ Object
259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/bureaucrat/fields.rb', line 259 def to_object(value) if Validators.empty_value?(value) return nil end begin Utils.make_float(value.to_s) rescue ArgumentError raise ValidationError.new([:invalid]) end end |