Soft Validations plugin
Plugin details
Documentation
Use SoftValidations::Validation#soft_validation to add a descriptive declaration of an ActiveRecord object's desired state in order to be considered complete. The methods or block passed to soft_validate should add a message to the class's warning collection.
class Employee < ActiveRecord::Base soft_validate :should_have_first_name protected def should_have_first_name warnings.add(:first_name, "shouldn't be blank") unless attribute_present?(:first_name) end end
To generate warnings, you should first call complete?
>> employee = Employee.new >> employee.complete? => false >> employee.warnings.on(:first_name) => "shouldn't be blank"
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: Guest, 9 months ago

