Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix syntax of AM::Validations::HelperMethods examples [ci skip]

  • Loading branch information...
commit 70c4676d88a11c7a6f0579d69c9e3de1e1cd024e 1 parent 68df230
Francesco Rodriguez authored
View
2  activemodel/lib/active_model/validations/exclusion.rb
@@ -22,7 +22,7 @@ module HelperMethods
# validates_exclusion_of :username, in: %w( admin superuser ), message: "You don't belong here"
# validates_exclusion_of :age, in: 30..60, message: 'This site is only for under 30 and over 60'
# validates_exclusion_of :format, in: %w( mov avi ), message: "extension %{value} is not allowed"
- # validates_exclusion_of :password, in: ->{ |p| [p.username, p.first_name] },
+ # validates_exclusion_of :password, in: ->(person) { [person.username, person.first_name] },
# message: 'should not be the same as your username or first name'
# end
#
View
2  activemodel/lib/active_model/validations/format.rb
@@ -73,7 +73,7 @@ module HelperMethods
# class Person < ActiveRecord::Base
# # Admin can have number as a first letter in their screen name
# validates_format_of :screen_name,
- # with: ->{ |person| person.admin? ? /\A[a-z0-9][a-z0-9_\-]*\z/i : /\A[a-z][a-z0-9_\-]*\z/i }
+ # with: ->(person) { person.admin? ? /\A[a-z0-9][a-z0-9_\-]*\z/i : /\A[a-z][a-z0-9_\-]*\z/i }
# end
#
# Note: use <tt>\A</tt> and <tt>\Z</tt> to match the start and end of the
View
2  activemodel/lib/active_model/validations/inclusion.rb
@@ -22,7 +22,7 @@ module HelperMethods
# validates_inclusion_of :gender, in: %w( m f )
# validates_inclusion_of :age, in: 0..99
# validates_inclusion_of :format, in: %w( jpg gif png ), message: "extension %{value} is not included in the list"
- # validates_inclusion_of :states, in: ->{ |person| STATES[person.country] }
+ # validates_inclusion_of :states, in: ->(person) { STATES[person.country] }
# end
#
# Configuration options:
View
6 activemodel/lib/active_model/validations/length.rb
@@ -74,7 +74,7 @@ module HelperMethods
# validates_length_of :zip_code, minimum: 5, too_short: 'please enter at least 5 characters'
# validates_length_of :smurf_leader, is: 4, message: "papa is spelled with 4 characters... don't play me."
# validates_length_of :essay, minimum: 100, too_short: 'Your essay must be at least 100 words.',
- # tokenizer: ->{ |str| str.scan(/\w+/) }
+ # tokenizer: ->(str) { str.scan(/\w+/) }
# end
#
# Configuration options:
@@ -109,8 +109,8 @@ module HelperMethods
# method, proc or string should return or evaluate to a +true+ or
# +false+ value.
# * <tt>:tokenizer</tt> - Specifies how to split up the attribute string.
- # (e.g. <tt>tokenizer: ->{|str| str.scan(/\w+/)}</tt> to count words
- # as in above example). Defaults to <tt>->{ |value| value.split(//) }</tt>
+ # (e.g. <tt>tokenizer: ->(str) { str.scan(/\w+/) }</tt> to count words
+ # as in above example). Defaults to <tt>->(value) { value.split(//) }</tt>
# which counts individual characters.
# * <tt>:strict</tt> - Specifies whether validation should be strict.
# See <tt>ActiveModel::Validation#validates!</tt> for more information.
Please sign in to comment.
Something went wrong with that request. Please try again.