Permalink
Browse files

Merge pull request #28966 from stve/active-model-uniqueness-validators

remove uniqueness validators from ActiveModel examples [ci-skip]
  • Loading branch information...
guilleiguaran committed May 3, 2017
2 parents c5305f6 + 0a5e87d commit 855a9f1705d9afbd8af6a498577b4f1da900b338
@@ -18,7 +18,6 @@ module ClassMethods
# 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 ClassMethods
# 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 ClassMethods
# 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+
@@ -97,7 +97,7 @@ class Validator
# 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 @@ def initialize(options = {})
# Returns the kind for this validator.
#
# PresenceValidator.new.kind # => :presence
# UniquenessValidator.new.kind # => :uniqueness
# AcceptanceValidator.new.kind # => :acceptance
def kind
self.class.kind
end

0 comments on commit 855a9f1

Please sign in to comment.