test/scalar_test.rb in reform-1.1.0 vs test/scalar_test.rb in reform-1.1.1
- old
+ new
@@ -161,7 +161,25 @@
it do
form = StringForm.new(AlbumCover.new(nil))
form.validate({}).must_equal true
end
+
+ it do
+ form = StringForm.new(AlbumCover.new(nil))
+ form.validate({"image"=>""}).must_equal true
+ end
+
+
+
+ # TODO: move to validate_test.
+ # property :rejection_reason, scalar: true, virtual: true, empty: true do # optional parameter
+ # validates length: {minimum: 5}, if: lambda { model.present? and avatar_moderation == "2" } # IF present, at least 5 characters.
+ # end
+ class BlaForm < Reform::Form
+ property :image# creates "empty" form
+ validates :image, :length => {:minimum => 10}, if: lambda { image and image != "" }
+ end
+
+ it { BlaForm.new(AlbumCover.new(nil)).validate({"image"=>""}).must_equal true }
# DISCUSS: when AlbumCover.new("Hello").validate({}), does that fail?
end
\ No newline at end of file