Module: NestedValidation

Defined in:
lib/nested_validation.rb

Overview

Module NestedValidation provides an ActiveModel compatible version of validates associated. Unlike the active model version however it actually propagates the error outwards.

Usage:

class MyHappyClass

extend NestedValidation

validates_nested :my_other_active_model_object

end

Defined Under Namespace

Classes: NestedValidator

Instance Method Summary collapse

Instance Method Details

#validates_nested(*attr_names) ⇒ NestedValidator

Records of this class will call valid? on any associations provided as attr_names. Errors on these records will be propagated out

Parameters:

  • *attr_names (Symbol)

    One or more associations to validate

Returns:


44
45
46
# File 'lib/nested_validation.rb', line 44

def validates_nested(*attr_names)
  validates_with NestedValidator, _merge_attributes(attr_names)
end