Changeset 8832
- Timestamp:
- 02/10/08 01:05:54 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2-0-stable/activerecord/lib/active_record/validations.rb
r8379 r8832 708 708 # Configuration options: 709 709 # * <tt>message</tt> - A custom error message (default is: "is invalid") 710 # * <tt>allow_nil</tt> - If set to true, skips this validation if the attribute is null (default is: false) 711 # * <tt>allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is: false) 710 712 # * <tt>with</tt> - The regular expression used to validate the format with (note: must be supplied!) 711 713 # * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update) branches/2-0-stable/activerecord/test/validations_test.rb
r8487 r8832 481 481 assert_raise(ArgumentError) { Topic.validates_format_of(:title, :content) } 482 482 end 483 484 def test_validate_format_with_allow_blank 485 Topic.validates_format_of(:title, :with => /^Validation\smacros \w+!$/, :allow_blank=>true) 486 assert !Topic.create("title" => "Shouldn't be valid").valid? 487 assert Topic.create("title" => "").valid? 488 assert Topic.create("title" => nil).valid? 489 assert Topic.create("title" => "Validation macros rule!").valid? 490 end 483 491 484 492 # testing ticket #3142