README.md in rails-settings-cached-2.5.0 vs README.md in rails-settings-cached-2.5.1

- old
+ new

@@ -160,12 +160,26 @@ field :app_name, default: "Rails Settings", validates: { presence: true, length: { in: 2..20 } } field :default_locale, default: "zh-CN", validates: { presence: true, inclusion: { in: %w[zh-CN en jp], message: "is not included in [zh-CN, en, jp]" } } end ``` -Now validate will work on record save. +Now validate will work on record save: ```rb +irb> Setting.app_name = "" +ActiveRecord::RecordInvalid: (Validation failed: App name can't be blank) +irb> Setting.app_name = "Rails Settings" +"Rails Settings" +irb> Setting.default_locale = "zh-TW" +ActiveRecord::RecordInvalid: (Validation failed: Default locale is not included in [zh-CN, en, jp]) +irb> Setting.default_locale = "en" +"en" +``` + +Validate by `save` / `valid?` method: + +```rb + setting = Setting.find_or_initialize_by(var: :app_name) setting.value = "" setting.valid? # => false setting.errors.full_messages