diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-07-05 11:19:20 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-07-05 11:19:20 -0500 |
commit | 70c4676d88a11c7a6f0579d69c9e3de1e1cd024e (patch) | |
tree | 4c083ffb0390c8f604bf49ebebbb79160ad95fd4 /activemodel/lib | |
parent | 68df230255b39c0197a211de9d68ab263c65a093 (diff) | |
download | rails-70c4676d88a11c7a6f0579d69c9e3de1e1cd024e.tar.gz rails-70c4676d88a11c7a6f0579d69c9e3de1e1cd024e.tar.bz2 rails-70c4676d88a11c7a6f0579d69c9e3de1e1cd024e.zip |
fix syntax of AM::Validations::HelperMethods examples [ci skip]
Diffstat (limited to 'activemodel/lib')
4 files changed, 6 insertions, 6 deletions
diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb index beb26ad5f2..a9a1af039c 100644 --- a/activemodel/lib/active_model/validations/exclusion.rb +++ b/activemodel/lib/active_model/validations/exclusion.rb @@ -22,7 +22,7 @@ module ActiveModel # 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 # diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb index 1755689215..a2126f8372 100644 --- a/activemodel/lib/active_model/validations/format.rb +++ b/activemodel/lib/active_model/validations/format.rb @@ -73,7 +73,7 @@ module ActiveModel # 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 diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb index d97c5779d1..e7ad07f040 100644 --- a/activemodel/lib/active_model/validations/inclusion.rb +++ b/activemodel/lib/active_model/validations/inclusion.rb @@ -22,7 +22,7 @@ module ActiveModel # 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: diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index 5b465c19c6..3b0be96ac6 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -74,7 +74,7 @@ module ActiveModel # 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 ActiveModel # 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. |