Changeset 8733
- Timestamp:
- 01/26/08 05:08:20 (9 months ago)
- Files:
-
- trunk/activerecord/lib/active_record/validations.rb (modified) (1 diff)
- trunk/activerecord/test/cases/validations_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/lib/active_record/validations.rb
r8664 r8733 685 685 # Configuration options: 686 686 # * <tt>message</tt> - A custom error message (default is: "is invalid") 687 # * <tt>allow_nil</tt> - If set to true, skips this validation if the attribute is null (default is: false) 688 # * <tt>allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is: false) 687 689 # * <tt>with</tt> - The regular expression used to validate the format with (note: must be supplied!) 688 690 # * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update) trunk/activerecord/test/cases/validations_test.rb
r8681 r8733 488 488 489 489 assert_raise(ArgumentError) { Topic.validates_format_of(:title, :content) } 490 end 491 492 def test_validate_format_with_allow_blank 493 Topic.validates_format_of(:title, :with => /^Validation\smacros \w+!$/, :allow_blank=>true) 494 assert !Topic.create("title" => "Shouldn't be valid").valid? 495 assert Topic.create("title" => "").valid? 496 assert Topic.create("title" => nil).valid? 497 assert Topic.create("title" => "Validation macros rule!").valid? 490 498 end 491 499