1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

remove uniqueness validators from ActiveModel examples

This commit is contained in:
stve 2017-05-02 22:27:45 -04:00
parent a23846e0ab
commit 0a5e87d16b
No known key found for this signature in database
GPG key ID: FDAF2BA50D34F744
2 changed files with 4 additions and 5 deletions

View file

@ -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+

View file

@ -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