Module: Phlexi::Form::Options::Errors
- Included in:
- Builder
- Defined in:
- lib/phlexi/form/options/errors.rb
Instance Method Summary collapse
- #can_show_errors? ⇒ Boolean
- #custom_error(error) ⇒ Object
- #error ⇒ Object
- #full_error ⇒ Object
- #has_errors? ⇒ Boolean
-
#object_valid? ⇒ Boolean
Determines if the associated object is in a valid state.
- #show_errors? ⇒ Boolean
- #valid? ⇒ Boolean
Instance Method Details
#can_show_errors? ⇒ Boolean
24 25 26 |
# File 'lib/phlexi/form/options/errors.rb', line 24 def can_show_errors? [:error] != false end |
#custom_error(error) ⇒ Object
7 8 9 10 |
# File 'lib/phlexi/form/options/errors.rb', line 7 def custom_error(error) [:error] = error self end |
#error ⇒ Object
12 13 14 |
# File 'lib/phlexi/form/options/errors.rb', line 12 def error error_text if has_errors? end |
#full_error ⇒ Object
16 17 18 |
# File 'lib/phlexi/form/options/errors.rb', line 16 def full_error full_error_text if has_errors? end |
#has_errors? ⇒ Boolean
20 21 22 |
# File 'lib/phlexi/form/options/errors.rb', line 20 def has_errors? object_with_errors? || !object && has_custom_error? end |
#object_valid? ⇒ Boolean
Determines if the associated object is in a valid state
An object is considered valid if it is persisted and has no errors.
41 42 43 44 |
# File 'lib/phlexi/form/options/errors.rb', line 41 def object_valid? object.respond_to?(:persisted?) && object.persisted? && object.respond_to?(:errors) && !object.errors.empty? end |
#show_errors? ⇒ Boolean
28 29 30 |
# File 'lib/phlexi/form/options/errors.rb', line 28 def show_errors? can_show_errors? && has_errors? end |
#valid? ⇒ Boolean
32 33 34 |
# File 'lib/phlexi/form/options/errors.rb', line 32 def valid? !has_errors? && has_value? end |