reform 2.2.4 → 2.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -7
- data/CHANGES.md +26 -4
- data/CONTRIBUTING.md +31 -0
- data/Gemfile +1 -12
- data/ISSUE_TEMPLATE.md +25 -0
- data/LICENSE.txt +1 -1
- data/README.md +3 -3
- data/lib/reform.rb +1 -0
- data/lib/reform/contract.rb +1 -11
- data/lib/reform/contract/validate.rb +49 -23
- data/lib/reform/errors.rb +49 -0
- data/lib/reform/form.rb +20 -5
- data/lib/reform/form/dry.rb +57 -29
- data/lib/reform/form/populator.rb +2 -16
- data/lib/reform/form/prepopulate.rb +1 -1
- data/lib/reform/form/validate.rb +10 -2
- data/lib/reform/result.rb +63 -0
- data/lib/reform/validation.rb +19 -13
- data/lib/reform/validation/groups.rb +11 -25
- data/lib/reform/version.rb +1 -1
- data/reform.gemspec +7 -6
- data/test/benchmarking.rb +39 -5
- data/test/call_test.rb +1 -1
- data/test/changed_test.rb +1 -1
- data/test/coercion_test.rb +2 -2
- data/test/composition_test.rb +47 -9
- data/test/contract_test.rb +5 -5
- data/test/default_test.rb +1 -1
- data/test/deserialize_test.rb +3 -3
- data/test/errors_test.rb +36 -21
- data/test/feature_test.rb +1 -1
- data/test/fixtures/dry_error_messages.yml +70 -23
- data/test/form_option_test.rb +3 -3
- data/test/form_test.rb +3 -3
- data/test/from_test.rb +2 -2
- data/test/inherit_test.rb +44 -51
- data/test/module_test.rb +12 -12
- data/test/parse_option_test.rb +40 -0
- data/test/parse_pipeline_test.rb +2 -2
- data/test/populate_test.rb +59 -19
- data/test/populator_skip_test.rb +9 -8
- data/test/prepopulator_test.rb +3 -3
- data/test/readable_test.rb +2 -2
- data/test/readonly_test.rb +1 -1
- data/test/reform_test.rb +16 -31
- data/test/save_test.rb +23 -8
- data/test/setup_test.rb +2 -2
- data/test/skip_if_test.rb +4 -4
- data/test/skip_setter_and_getter_test.rb +1 -1
- data/test/test_helper.rb +13 -10
- data/test/validate_test.rb +18 -18
- data/test/validation/dry_validation_test.rb +430 -117
- data/test/validation/result_test.rb +79 -0
- data/test/validation_library_provided_test.rb +16 -0
- data/test/virtual_test.rb +1 -1
- data/test/writeable_test.rb +31 -2
- metadata +42 -23
- data/gemfiles/Gemfile.disposable-0.3 +0 -6
- data/lib/reform/contract/errors.rb +0 -43
- data/lib/reform/form/mongoid.rb +0 -37
- data/lib/reform/form/orm.rb +0 -26
- data/lib/reform/mongoid.rb +0 -4
- data/test/deprecation_test.rb +0 -27
- data/test/validation/dry_test.rb +0 -60
- data/test/validation/errors.yml +0 -4
data/lib/reform/mongoid.rb
DELETED
data/test/deprecation_test.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
|
4
|
-
class DeprecationRemoveMePopulatorTest < MiniTest::Spec
|
5
|
-
Album = Struct.new(:songs)
|
6
|
-
Song = Struct.new(:title)
|
7
|
-
|
8
|
-
|
9
|
-
class AlbumForm < Reform::Form
|
10
|
-
collection :songs, populator: ->(fragment, collection, index, *) { return Representable::Pipeline::Stop if fragment[:title]=="Good"
|
11
|
-
songs[index]
|
12
|
-
} do
|
13
|
-
property :title
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
it do
|
18
|
-
form = AlbumForm.new(Album.new([Song.new, Song.new]))
|
19
|
-
hash = {songs: [{title: "Good"}, {title: "Bad"}]}
|
20
|
-
|
21
|
-
form.validate(hash)
|
22
|
-
|
23
|
-
form.songs.size.must_equal 2
|
24
|
-
form.songs[0].title.must_equal nil
|
25
|
-
form.songs[1].title.must_equal "Bad"
|
26
|
-
end
|
27
|
-
end
|
data/test/validation/dry_test.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# require "test_helper"
|
2
|
-
# require "reform/form/dry"
|
3
|
-
|
4
|
-
# class BlaTest < MiniTest::Spec
|
5
|
-
# class CartForm < Reform::Form
|
6
|
-
# include Reform::Form::Dry::Validations
|
7
|
-
|
8
|
-
# property :user_id
|
9
|
-
|
10
|
-
# collection :variants do
|
11
|
-
# property :id
|
12
|
-
# end
|
13
|
-
|
14
|
-
|
15
|
-
# validation :default do
|
16
|
-
# key(:user_id).required
|
17
|
-
|
18
|
-
# key(:variants).schema do
|
19
|
-
# each do
|
20
|
-
# key(:id).required
|
21
|
-
# end
|
22
|
-
# end
|
23
|
-
|
24
|
-
# configure do
|
25
|
-
# config.messages_file = 'test/validation/errors.yml'
|
26
|
-
|
27
|
-
# option :form
|
28
|
-
# # message need to be defined on fixtures/dry_error_messages
|
29
|
-
# # d-v expects you to define your custome messages on the .yml file
|
30
|
-
|
31
|
-
|
32
|
-
# def form_access_validation?(value)
|
33
|
-
# raise value.inspect
|
34
|
-
# form.title == 'Reform'
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
|
38
|
-
# rule(form_present: [:form]) do |form|
|
39
|
-
# form.user_id == "hallo"
|
40
|
-
# end
|
41
|
-
# end
|
42
|
-
# end
|
43
|
-
|
44
|
-
# it do
|
45
|
-
# cart = Struct.new(:user_id, :variants).new(1, [Struct.new(:id).new])
|
46
|
-
|
47
|
-
# form = CartForm.new(cart)
|
48
|
-
# form.validate(user_id: 2, variants: [{id: 3}])
|
49
|
-
# puts form.errors.inspect
|
50
|
-
# end
|
51
|
-
# end
|
52
|
-
|
53
|
-
|
54
|
-
# # current_id: BlaTest
|
55
|
-
# # cart: {
|
56
|
-
# # carts: {
|
57
|
-
# # products: [{current_id}]
|
58
|
-
# # }
|
59
|
-
|
60
|
-
# # }
|
data/test/validation/errors.yml
DELETED