diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2017-05-02 21:44:36 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-02 21:44:36 -0500 |
commit | 855a9f1705d9afbd8af6a498577b4f1da900b338 (patch) | |
tree | 46229918f7d4e0bfcb7bcaf04f5b343d4a1357f1 /activemodel/lib/active_model | |
parent | c5305f6fdfd46349a6f0646c3e599b9ed706f59a (diff) | |
parent | 0a5e87d16b9ffb95b391a446cb2484833b5f33d6 (diff) | |
download | rails-855a9f1705d9afbd8af6a498577b4f1da900b338.tar.gz rails-855a9f1705d9afbd8af6a498577b4f1da900b338.tar.bz2 rails-855a9f1705d9afbd8af6a498577b4f1da900b338.zip |
Merge pull request #28966 from stve/active-model-uniqueness-validators
remove uniqueness validators from ActiveModel examples [ci-skip]
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/validations/validates.rb | 5 | ||||
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 4 |
2 files changed, 4 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index 0ce5935f3a..a8b958e974 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -18,7 +18,6 @@ module ActiveModel # validates :first_name, length: { maximum: 30 } # validates :age, numericality: true # validates :username, presence: true - # validates :username, uniqueness: true # # The power of the +validates+ method comes when using custom validators # and default validators in one call for a given attribute. @@ -34,7 +33,7 @@ module ActiveModel # include ActiveModel::Validations # attr_accessor :name, :email # - # validates :name, presence: true, uniqueness: true, length: { maximum: 100 } + # validates :name, presence: true, length: { maximum: 100 } # validates :email, presence: true, email: true # end # @@ -94,7 +93,7 @@ module ActiveModel # Example: # # validates :password, presence: true, confirmation: true, if: :password_required? - # validates :token, uniqueness: true, strict: TokenGenerationException + # validates :token, length: 24, strict: TokenLengthException # # # Finally, the options +:if+, +:unless+, +:on+, +:allow_blank+, +:allow_nil+, +:strict+ diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 98234e9b6b..0032200ef7 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -97,7 +97,7 @@ module ActiveModel # Returns the kind of the validator. # # PresenceValidator.kind # => :presence - # UniquenessValidator.kind # => :uniqueness + # AcceptanceValidator.kind # => :acceptance def self.kind @kind ||= name.split("::").last.underscore.chomp("_validator").to_sym unless anonymous? end @@ -110,7 +110,7 @@ module ActiveModel # Returns the kind for this validator. # # PresenceValidator.new.kind # => :presence - # UniquenessValidator.new.kind # => :uniqueness + # AcceptanceValidator.new.kind # => :acceptance def kind self.class.kind end |