README.md in active_warnings-0.1.3 vs README.md in active_warnings-0.1.4

- old
+ new

@@ -1,8 +1,8 @@ # ActiveWarnings [![Build Status](https://travis-ci.org/s12chung/active_warnings.svg?branch=test_active_model)](https://travis-ci.org/s12chung/active_warnings) -`ActiveModel::Validations` separate for warnings. +Separate `ActiveModel::Validations` errors for warnings. ## Installation Add this line to your application's Gemfile: @@ -25,30 +25,34 @@ include ActiveWarnings attr_accessor :name def initialize(name); @name = name; end - validates :name, presence: true - warnings do - # to share the same validators, error related methods now correspond to warnings. ie: - # the method #valid? == #safe? and #errors == #warnings validates :name, absence: true + + # Example custom validation + validate { errors.add(:name, "is some_name") if name == "some_name" } end end # # Basic Use # model = BasicModel.new("some_name") -model.valid? # => true -model.errors.keys # => [] +# Regular ActiveModel::Validations errors work separately +model.valid? # => true +model.errors.full_messages # => [] + +# like `#valid?` model.safe? # => false model.no_warnings? # => false, equivalent to #safe? +# like `#invalid?` model.unsafe? # => true model.has_warnings? # => true, equivalent to #unsafe? -model.warnings.keys # => [:name] +# like `#errors` +model.warnings.full_messages # => ["Name must be blank", "Name is some_name"] # # Advanced Use # model.using_warnings? # => false, is true in validators when calling #safe?