Module: PageRecord::Validations
- Included in:
- Base
- Defined in:
- lib/page_record/validations.rb
Instance Method Summary collapse
-
#errors ⇒ ActiveModel::Errors
Searches the record for any errors and returns them.
-
#invalid? ⇒ Boolean
Returns true of there are errors on the current record.
-
#valid? ⇒ Boolean
Returns true of there are no errors on the current record.
Instance Method Details
#errors ⇒ ActiveModel::Errors
Searches the record for any errors and returns them
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/page_record/validations.rb', line 12 def errors found_errors = @record.all('[data-error-for]') error_list = ActiveModel::Errors.new(self) found_errors.each do | error | attribute = error['data-error-for'] = error.text error_list.add(attribute, ) end error_list end |
#invalid? ⇒ Boolean
Returns true of there are errors on the current record
41 42 43 |
# File 'lib/page_record/validations.rb', line 41 def invalid? !valid? end |
#valid? ⇒ Boolean
Returns true of there are no errors on the current record
30 31 32 |
# File 'lib/page_record/validations.rb', line 30 def valid? errors.empty? end |