diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-10-25 20:41:35 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-10-25 20:41:35 -0500 |
commit | 9ac095fef586bcf86ed10d31acbc4af2abb53843 (patch) | |
tree | b89cc16129b877ad770e6aabc0cca003a31fbc24 /activemodel/lib/active_model/validations | |
parent | 65be1a0e7a93b2f4e308739d55516be0c58543df (diff) | |
download | rails-9ac095fef586bcf86ed10d31acbc4af2abb53843.tar.gz rails-9ac095fef586bcf86ed10d31acbc4af2abb53843.tar.bz2 rails-9ac095fef586bcf86ed10d31acbc4af2abb53843.zip |
minor edits and remove mixed titles in AM::Validations docs [ci skip]
Diffstat (limited to 'activemodel/lib/active_model/validations')
9 files changed, 13 insertions, 21 deletions
diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index ec7ad4b048..0935ad0d2a 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -1,8 +1,7 @@ module ActiveModel - # == Active \Model Acceptance \Validator module Validations - class AcceptanceValidator < EachValidator #:nodoc: + class AcceptanceValidator < EachValidator # :nodoc: def initialize(options) super({ :allow_nil => true, :accept => "1" }.merge!(options)) end @@ -27,7 +26,7 @@ module ActiveModel # # class Person < ActiveRecord::Base # validates_acceptance_of :terms_of_service - # validates_acceptance_of :eula, message: "must be abided" + # validates_acceptance_of :eula, message: 'must be abided' # end # # If the database column does not exist, the +terms_of_service+ attribute diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb index 4071589747..3a3abce364 100644 --- a/activemodel/lib/active_model/validations/confirmation.rb +++ b/activemodel/lib/active_model/validations/confirmation.rb @@ -1,8 +1,7 @@ module ActiveModel - # == Active \Model Confirmation \Validator module Validations - class ConfirmationValidator < EachValidator #:nodoc: + class ConfirmationValidator < EachValidator # :nodoc: def validate_each(record, attribute, value) if (confirmed = record.send("#{attribute}_confirmation")) && (value != confirmed) human_attribute_name = record.class.human_attribute_name(attribute) diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb index 7a90750c49..b7f38e48f5 100644 --- a/activemodel/lib/active_model/validations/exclusion.rb +++ b/activemodel/lib/active_model/validations/exclusion.rb @@ -2,9 +2,8 @@ require "active_model/validations/clusivity" module ActiveModel - # == Active \Model Exclusion \Validator module Validations - class ExclusionValidator < EachValidator #:nodoc: + class ExclusionValidator < EachValidator # :nodoc: include Clusivity def validate_each(record, attribute, value) diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb index 80150229a0..9398b7e66e 100644 --- a/activemodel/lib/active_model/validations/format.rb +++ b/activemodel/lib/active_model/validations/format.rb @@ -1,8 +1,7 @@ module ActiveModel - # == Active Model Format Validator module Validations - class FormatValidator < EachValidator #:nodoc: + class FormatValidator < EachValidator # :nodoc: def validate_each(record, attribute, value) if options[:with] regexp = option_call(record, :with) diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb index a333a09976..5e45a04c2c 100644 --- a/activemodel/lib/active_model/validations/inclusion.rb +++ b/activemodel/lib/active_model/validations/inclusion.rb @@ -2,9 +2,8 @@ require "active_model/validations/clusivity" module ActiveModel - # == Active \Model Inclusion \Validator module Validations - class InclusionValidator < EachValidator #:nodoc: + class InclusionValidator < EachValidator # :nodoc: include Clusivity def validate_each(record, attribute, value) diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index ffd045a8fb..744c196d30 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -1,6 +1,5 @@ module ActiveModel - # == Active \Model Numericality \Validator module Validations class NumericalityValidator < EachValidator # :nodoc: CHECKS = { :greater_than => :>, :greater_than_or_equal_to => :>=, @@ -126,7 +125,7 @@ module ActiveModel # For example: # # class Person < ActiveRecord::Base - # validates_numericality_of :width, less_than: Proc.new { |person| person.height } + # validates_numericality_of :width, less_than: ->(person) { person.height } # validates_numericality_of :width, greater_than: :minimum_weight # end def validates_numericality_of(*attr_names) diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb index 70247ee4c8..ae84c376b9 100644 --- a/activemodel/lib/active_model/validations/presence.rb +++ b/activemodel/lib/active_model/validations/presence.rb @@ -1,7 +1,6 @@ module ActiveModel - # == Active \Model Presence \Validator module Validations class PresenceValidator < EachValidator # :nodoc: def validate(record) diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index 03046a543a..4651154934 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -1,7 +1,6 @@ require 'active_support/core_ext/hash/slice' module ActiveModel - # == Active Model validates method module Validations module ClassMethods # This method is a shortcut to all default validators and any custom @@ -129,15 +128,15 @@ module ActiveModel # the validation itself. # # class Person - # include ActiveModel::Validations + # include ActiveModel::Validations # # attr_accessor :name # validates! :name, presence: true # end # # person = Person.new - # person.name = '' - # person.valid? + # person.name = '' + # person.valid? # # => ActiveModel::StrictValidationFailed: Name can't be blank def validates!(*attributes) options = attributes.extract_options! @@ -149,11 +148,11 @@ module ActiveModel # When creating custom validators, it might be useful to be able to specify # additional default keys. This can be done by overwriting this method. - def _validates_default_keys #:nodoc: + def _validates_default_keys # :nodoc: [:if, :unless, :on, :allow_blank, :allow_nil , :strict] end - def _parse_validates_options(options) #:nodoc: + def _parse_validates_options(options) # :nodoc: case options when TrueClass {} diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb index 869591cd9e..2ae335d0f4 100644 --- a/activemodel/lib/active_model/validations/with.rb +++ b/activemodel/lib/active_model/validations/with.rb @@ -10,7 +10,7 @@ module ActiveModel end end - class WithValidator < EachValidator #:nodoc: + class WithValidator < EachValidator # :nodoc: def validate_each(record, attr, val) method_name = options[:with] |