Permalink
Browse files

minor edits and remove mixed titles in AM::Validations docs [ci skip]

  • Loading branch information...
1 parent 65be1a0 commit 9ac095fef586bcf86ed10d31acbc4af2abb53843 Francesco Rodriguez committed Oct 26, 2012
@@ -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 HelperMethods
#
# 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
@@ -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)
@@ -2,9 +2,8 @@
module ActiveModel
- # == Active \Model Exclusion \Validator
module Validations
- class ExclusionValidator < EachValidator #:nodoc:
+ class ExclusionValidator < EachValidator # :nodoc:
include Clusivity
def validate_each(record, attribute, value)
@@ -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)
@@ -2,9 +2,8 @@
module ActiveModel
- # == Active \Model Inclusion \Validator
module Validations
- class InclusionValidator < EachValidator #:nodoc:
+ class InclusionValidator < EachValidator # :nodoc:
include Clusivity
def validate_each(record, attribute, value)
@@ -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 HelperMethods
# 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)
@@ -1,7 +1,6 @@
module ActiveModel
- # == Active \Model Presence \Validator
module Validations
class PresenceValidator < EachValidator # :nodoc:
def validate(record)
@@ -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 @@ def validates(*attributes)
# 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 @@ def validates!(*attributes)
# 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
{}
@@ -10,7 +10,7 @@ def _merge_attributes(attr_names)
end
end
- class WithValidator < EachValidator #:nodoc:
+ class WithValidator < EachValidator # :nodoc:
def validate_each(record, attr, val)
method_name = options[:with]

0 comments on commit 9ac095f

Please sign in to comment.