reform-rails 0.2.0.rc1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -1
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +661 -0
- data/.travis.yml +10 -18
- data/CHANGES.md +16 -1
- data/Gemfile +25 -9
- data/LICENSE.txt +1 -1
- data/README.md +4 -4
- data/lib/reform/active_record.rb +2 -1
- data/lib/reform/form/active_model/result.rb +15 -0
- data/lib/reform/form/active_model/validations.rb +73 -5
- data/lib/reform/form/active_record.rb +0 -2
- data/lib/reform/form/mongoid.rb +3 -14
- data/lib/reform/form/orm.rb +4 -1
- data/lib/reform/mongoid.rb +1 -1
- data/lib/reform/rails.rb +1 -0
- data/lib/reform/rails/railtie.rb +4 -5
- data/lib/reform/rails/version.rb +1 -1
- data/reform-rails.gemspec +5 -12
- metadata +15 -126
- data/database.sqlite3 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 754bad405b747f3fb7e2ea5bfb46ca9e32262eb0f17c85d9804312da30adaa6f
|
4
|
+
data.tar.gz: 1a5643a5b733a4f536964e4ea33b5a38ee645cd752696d337a97cb824b72f442
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9f24f96751b877f6dd57da25502dbf7bdc23362e255ff78b677c18c3d51a3ffdc2b30ea101831fb2ce8a2b8e1cef665e968cd57c7394e0d897e8a8d2054eab3
|
7
|
+
data.tar.gz: 129b85d74bcb7c45552991b0d76af9f4955119a9a57fb44d56620970ef935f8a8df3667db1b5088c5836c1c0f8c72367c8d80a9876448e21019cf5a3026de66d
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,661 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-10-31 18:47:53 +1100 using RuboCop version 0.76.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 3
|
10
|
+
# Configuration parameters: Include.
|
11
|
+
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
12
|
+
Bundler/DuplicatedGem:
|
13
|
+
Exclude:
|
14
|
+
- 'Gemfile'
|
15
|
+
|
16
|
+
# Offense count: 1
|
17
|
+
# Cop supports --auto-correct.
|
18
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, Include.
|
19
|
+
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
20
|
+
Bundler/OrderedGems:
|
21
|
+
Exclude:
|
22
|
+
- 'Gemfile'
|
23
|
+
|
24
|
+
# Offense count: 1
|
25
|
+
# Cop supports --auto-correct.
|
26
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, Include.
|
27
|
+
# Include: **/*.gemspec
|
28
|
+
Gemspec/OrderedDependencies:
|
29
|
+
Exclude:
|
30
|
+
- 'reform-rails.gemspec'
|
31
|
+
|
32
|
+
# Offense count: 5
|
33
|
+
# Cop supports --auto-correct.
|
34
|
+
# Configuration parameters: IndentationWidth.
|
35
|
+
# SupportedStyles: outdent, indent
|
36
|
+
Layout/AccessModifierIndentation:
|
37
|
+
EnforcedStyle: outdent
|
38
|
+
|
39
|
+
# Offense count: 13
|
40
|
+
# Cop supports --auto-correct.
|
41
|
+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
42
|
+
# SupportedHashRocketStyles: key, separator, table
|
43
|
+
# SupportedColonStyles: key, separator, table
|
44
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
45
|
+
Layout/AlignHash:
|
46
|
+
Exclude:
|
47
|
+
- 'test/activemodel_validation_test.rb'
|
48
|
+
- 'test/form_builder_test.rb'
|
49
|
+
- 'test/test_helper.rb'
|
50
|
+
|
51
|
+
# Offense count: 2
|
52
|
+
# Cop supports --auto-correct.
|
53
|
+
# Configuration parameters: EnforcedStyleAlignWith.
|
54
|
+
# SupportedStylesAlignWith: either, start_of_block, start_of_line
|
55
|
+
Layout/BlockAlignment:
|
56
|
+
Exclude:
|
57
|
+
- 'reform-rails.gemspec'
|
58
|
+
- 'test/activemodel_validation_test.rb'
|
59
|
+
|
60
|
+
# Offense count: 1
|
61
|
+
# Cop supports --auto-correct.
|
62
|
+
Layout/BlockEndNewline:
|
63
|
+
Exclude:
|
64
|
+
- 'test/active_model_custom_validation_translations_test.rb'
|
65
|
+
|
66
|
+
# Offense count: 2
|
67
|
+
# Cop supports --auto-correct.
|
68
|
+
Layout/CommentIndentation:
|
69
|
+
Exclude:
|
70
|
+
- 'lib/reform/form/active_model/validations.rb'
|
71
|
+
- 'test/activemodel_validation_test.rb'
|
72
|
+
|
73
|
+
# Offense count: 2
|
74
|
+
# Cop supports --auto-correct.
|
75
|
+
Layout/EmptyLineAfterGuardClause:
|
76
|
+
Exclude:
|
77
|
+
- 'lib/reform/form/active_model.rb'
|
78
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
79
|
+
|
80
|
+
# Offense count: 1
|
81
|
+
# Cop supports --auto-correct.
|
82
|
+
Layout/EmptyLineAfterMagicComment:
|
83
|
+
Exclude:
|
84
|
+
- 'reform-rails.gemspec'
|
85
|
+
|
86
|
+
# Offense count: 2
|
87
|
+
# Cop supports --auto-correct.
|
88
|
+
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
|
89
|
+
Layout/EmptyLineBetweenDefs:
|
90
|
+
Exclude:
|
91
|
+
- 'lib/reform/form/active_record.rb'
|
92
|
+
- 'lib/reform/form/mongoid.rb'
|
93
|
+
|
94
|
+
# Offense count: 32
|
95
|
+
# Cop supports --auto-correct.
|
96
|
+
Layout/EmptyLines:
|
97
|
+
Exclude:
|
98
|
+
- 'lib/reform/form/active_model.rb'
|
99
|
+
- 'lib/reform/form/active_model/validations.rb'
|
100
|
+
- 'test/active_model_custom_validation_translations_test.rb'
|
101
|
+
- 'test/active_model_test.rb'
|
102
|
+
- 'test/active_record_test.rb'
|
103
|
+
- 'test/activemodel_validation_test.rb'
|
104
|
+
- 'test/form_builder_test.rb'
|
105
|
+
- 'test/model_reflections_test.rb'
|
106
|
+
- 'test/mongoid_test.rb'
|
107
|
+
- 'test/multi_parameter_attributes_test.rb'
|
108
|
+
- 'test/test_helper.rb'
|
109
|
+
- 'test/unique_test.rb'
|
110
|
+
|
111
|
+
# Offense count: 3
|
112
|
+
# Cop supports --auto-correct.
|
113
|
+
# Configuration parameters: EnforcedStyle.
|
114
|
+
# SupportedStyles: around, only_before
|
115
|
+
Layout/EmptyLinesAroundAccessModifier:
|
116
|
+
Exclude:
|
117
|
+
- 'lib/reform/form/active_model.rb'
|
118
|
+
- 'lib/reform/form/active_model/form_builder_methods.rb'
|
119
|
+
- 'lib/reform/form/multi_parameter_attributes.rb'
|
120
|
+
|
121
|
+
# Offense count: 7
|
122
|
+
# Cop supports --auto-correct.
|
123
|
+
# Configuration parameters: EnforcedStyle.
|
124
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
125
|
+
Layout/EmptyLinesAroundBlockBody:
|
126
|
+
Exclude:
|
127
|
+
- 'test/activemodel_validation_test.rb'
|
128
|
+
- 'test/custom_validation_test.rb'
|
129
|
+
- 'test/model_validations_test.rb'
|
130
|
+
|
131
|
+
# Offense count: 10
|
132
|
+
# Cop supports --auto-correct.
|
133
|
+
# Configuration parameters: EnforcedStyle.
|
134
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
|
135
|
+
Layout/EmptyLinesAroundClassBody:
|
136
|
+
Exclude:
|
137
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
138
|
+
- 'test/active_record_test.rb'
|
139
|
+
- 'test/custom_validation_test.rb'
|
140
|
+
- 'test/model_validations_test.rb'
|
141
|
+
- 'test/mongoid_test.rb'
|
142
|
+
|
143
|
+
# Offense count: 2
|
144
|
+
# Cop supports --auto-correct.
|
145
|
+
# Configuration parameters: EnforcedStyle.
|
146
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
|
147
|
+
Layout/EmptyLinesAroundModuleBody:
|
148
|
+
Exclude:
|
149
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
150
|
+
- 'lib/reform/form/active_model/validations.rb'
|
151
|
+
|
152
|
+
# Offense count: 1
|
153
|
+
# Cop supports --auto-correct.
|
154
|
+
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
155
|
+
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
156
|
+
Layout/EndAlignment:
|
157
|
+
Exclude:
|
158
|
+
- 'test/active_model_test.rb'
|
159
|
+
|
160
|
+
# Offense count: 4
|
161
|
+
# Cop supports --auto-correct.
|
162
|
+
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
163
|
+
Layout/ExtraSpacing:
|
164
|
+
Exclude:
|
165
|
+
- 'test/active_model_test.rb'
|
166
|
+
|
167
|
+
# Offense count: 1
|
168
|
+
# Cop supports --auto-correct.
|
169
|
+
Layout/FirstHashElementLineBreak:
|
170
|
+
Exclude:
|
171
|
+
- 'test/form_builder_test.rb'
|
172
|
+
|
173
|
+
# Offense count: 1
|
174
|
+
# Cop supports --auto-correct.
|
175
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
176
|
+
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
177
|
+
Layout/IndentFirstArgument:
|
178
|
+
Exclude:
|
179
|
+
- 'test/form_builder_test.rb'
|
180
|
+
|
181
|
+
# Offense count: 10
|
182
|
+
# Cop supports --auto-correct.
|
183
|
+
# Configuration parameters: EnforcedStyle.
|
184
|
+
# SupportedStyles: normal, indented_internal_methods
|
185
|
+
Layout/IndentationConsistency:
|
186
|
+
Exclude:
|
187
|
+
- 'test/active_model_test.rb'
|
188
|
+
|
189
|
+
# Offense count: 7
|
190
|
+
# Cop supports --auto-correct.
|
191
|
+
# Configuration parameters: Width, IgnoredPatterns.
|
192
|
+
Layout/IndentationWidth:
|
193
|
+
Exclude:
|
194
|
+
- 'lib/reform/form/active_model/form_builder_methods.rb'
|
195
|
+
- 'test/active_model_test.rb'
|
196
|
+
|
197
|
+
# Offense count: 2
|
198
|
+
# Cop supports --auto-correct.
|
199
|
+
# Configuration parameters: AllowDoxygenCommentStyle.
|
200
|
+
Layout/LeadingCommentSpace:
|
201
|
+
Exclude:
|
202
|
+
- 'test/docs/**/*'
|
203
|
+
- 'test/activemodel_validation_test.rb'
|
204
|
+
|
205
|
+
# Offense count: 1
|
206
|
+
# Cop supports --auto-correct.
|
207
|
+
Layout/MultilineBlockLayout:
|
208
|
+
Exclude:
|
209
|
+
- 'test/active_model_custom_validation_translations_test.rb'
|
210
|
+
|
211
|
+
# Offense count: 1
|
212
|
+
# Cop supports --auto-correct.
|
213
|
+
# Configuration parameters: EnforcedStyle.
|
214
|
+
# SupportedStyles: symmetrical, new_line, same_line
|
215
|
+
Layout/MultilineMethodCallBraceLayout:
|
216
|
+
Exclude:
|
217
|
+
- 'test/form_builder_test.rb'
|
218
|
+
|
219
|
+
# Offense count: 1
|
220
|
+
# Cop supports --auto-correct.
|
221
|
+
Layout/SpaceAfterColon:
|
222
|
+
Exclude:
|
223
|
+
- 'test/activemodel_validation_test.rb'
|
224
|
+
|
225
|
+
# Offense count: 7
|
226
|
+
# Cop supports --auto-correct.
|
227
|
+
Layout/SpaceAfterComma:
|
228
|
+
Exclude:
|
229
|
+
- 'lib/reform/form/active_model/model_reflections.rb'
|
230
|
+
- 'lib/reform/form/active_model/validations.rb'
|
231
|
+
- 'test/activemodel_validation_test.rb'
|
232
|
+
- 'test/test_helper.rb'
|
233
|
+
|
234
|
+
# Offense count: 1
|
235
|
+
# Cop supports --auto-correct.
|
236
|
+
Layout/SpaceAfterNot:
|
237
|
+
Exclude:
|
238
|
+
- 'lib/reform/form/active_model/validations.rb'
|
239
|
+
|
240
|
+
# Offense count: 7
|
241
|
+
# Cop supports --auto-correct.
|
242
|
+
# Configuration parameters: EnforcedStyle.
|
243
|
+
# SupportedStyles: space, no_space
|
244
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
245
|
+
Exclude:
|
246
|
+
- 'lib/reform/form/active_model.rb'
|
247
|
+
- 'lib/reform/form/active_model/form_builder_methods.rb'
|
248
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
249
|
+
- 'lib/reform/form/active_model/validations.rb'
|
250
|
+
- 'lib/reform/form/active_record.rb'
|
251
|
+
- 'lib/reform/form/mongoid.rb'
|
252
|
+
|
253
|
+
# Offense count: 1
|
254
|
+
# Cop supports --auto-correct.
|
255
|
+
Layout/SpaceAroundKeyword:
|
256
|
+
Exclude:
|
257
|
+
- 'test/active_record_test.rb'
|
258
|
+
|
259
|
+
# Offense count: 26
|
260
|
+
# Cop supports --auto-correct.
|
261
|
+
# Configuration parameters: AllowForAlignment.
|
262
|
+
Layout/SpaceAroundOperators:
|
263
|
+
Exclude:
|
264
|
+
- 'test/active_model_test.rb'
|
265
|
+
- 'test/active_record_test.rb'
|
266
|
+
- 'test/activemodel_validation_test.rb'
|
267
|
+
- 'test/form_builder_test.rb'
|
268
|
+
- 'test/form_test.rb'
|
269
|
+
- 'test/multi_parameter_attributes_test.rb'
|
270
|
+
|
271
|
+
# Offense count: 1
|
272
|
+
# Cop supports --auto-correct.
|
273
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
274
|
+
# SupportedStyles: space, no_space
|
275
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
276
|
+
Layout/SpaceBeforeBlockBraces:
|
277
|
+
Exclude:
|
278
|
+
- 'test/active_model_custom_validation_translations_test.rb'
|
279
|
+
|
280
|
+
# Offense count: 2
|
281
|
+
# Cop supports --auto-correct.
|
282
|
+
Layout/SpaceBeforeComment:
|
283
|
+
Exclude:
|
284
|
+
- 'test/activemodel_validation_test.rb'
|
285
|
+
|
286
|
+
# Offense count: 3
|
287
|
+
# Cop supports --auto-correct.
|
288
|
+
# Configuration parameters: AllowForAlignment.
|
289
|
+
Layout/SpaceBeforeFirstArg:
|
290
|
+
Exclude:
|
291
|
+
- 'test/active_model_test.rb'
|
292
|
+
- 'test/activemodel_validation_test.rb'
|
293
|
+
|
294
|
+
# Offense count: 19
|
295
|
+
# Cop supports --auto-correct.
|
296
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
297
|
+
# SupportedStyles: space, no_space
|
298
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
299
|
+
Layout/SpaceInsideBlockBraces:
|
300
|
+
Exclude:
|
301
|
+
- 'test/activemodel_validation_test.rb'
|
302
|
+
- 'test/mongoid_test.rb'
|
303
|
+
|
304
|
+
# Offense count: 34
|
305
|
+
# Cop supports --auto-correct.
|
306
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
307
|
+
# SupportedStyles: space, no_space, compact
|
308
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
309
|
+
Layout/SpaceInsideHashLiteralBraces:
|
310
|
+
Exclude:
|
311
|
+
- 'test/active_model_validation_for_property_named_format_test.rb'
|
312
|
+
- 'test/activemodel_validation_test.rb'
|
313
|
+
- 'test/form_test.rb'
|
314
|
+
- 'test/model_validations_test.rb'
|
315
|
+
- 'test/multi_parameter_attributes_test.rb'
|
316
|
+
- 'test/unique_test.rb'
|
317
|
+
|
318
|
+
# Offense count: 3
|
319
|
+
# Cop supports --auto-correct.
|
320
|
+
# Configuration parameters: EnforcedStyle.
|
321
|
+
# SupportedStyles: final_newline, final_blank_line
|
322
|
+
Layout/TrailingBlankLines:
|
323
|
+
Exclude:
|
324
|
+
- 'lib/reform/form/active_model/form_builder_methods.rb'
|
325
|
+
- 'test/active_record_test.rb'
|
326
|
+
- 'test/model_validations_test.rb'
|
327
|
+
|
328
|
+
# Offense count: 4
|
329
|
+
Lint/AmbiguousOperator:
|
330
|
+
Exclude:
|
331
|
+
- 'lib/reform/form/active_model.rb'
|
332
|
+
|
333
|
+
# Offense count: 1
|
334
|
+
# Configuration parameters: AllowSafeAssignment.
|
335
|
+
Lint/AssignmentInCondition:
|
336
|
+
Exclude:
|
337
|
+
- 'lib/reform/form/multi_parameter_attributes.rb'
|
338
|
+
|
339
|
+
# Offense count: 55
|
340
|
+
Lint/ParenthesesAsGroupedExpression:
|
341
|
+
Exclude:
|
342
|
+
- 'test/active_model_test.rb'
|
343
|
+
- 'test/active_record_test.rb'
|
344
|
+
- 'test/activemodel_validation_test.rb'
|
345
|
+
- 'test/form_builder_test.rb'
|
346
|
+
- 'test/model_reflections_test.rb'
|
347
|
+
- 'test/mongoid_test.rb'
|
348
|
+
- 'test/multi_parameter_attributes_test.rb'
|
349
|
+
- 'test/test_helper.rb'
|
350
|
+
- 'test/unique_test.rb'
|
351
|
+
|
352
|
+
# Offense count: 1
|
353
|
+
# Cop supports --auto-correct.
|
354
|
+
Lint/RedundantSplatExpansion:
|
355
|
+
Exclude:
|
356
|
+
- 'lib/reform/form/active_model.rb'
|
357
|
+
|
358
|
+
# Offense count: 1
|
359
|
+
# Configuration parameters: AllowKeywordBlockArguments.
|
360
|
+
Lint/UnderscorePrefixedVariableName:
|
361
|
+
Exclude:
|
362
|
+
- 'lib/reform/form/active_model.rb'
|
363
|
+
|
364
|
+
# Offense count: 3
|
365
|
+
# Cop supports --auto-correct.
|
366
|
+
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
|
367
|
+
Lint/UnusedBlockArgument:
|
368
|
+
Exclude:
|
369
|
+
- 'lib/reform/form/active_model/model_reflections.rb'
|
370
|
+
- 'lib/reform/form/orm.rb'
|
371
|
+
- 'test/activemodel_validation_test.rb'
|
372
|
+
|
373
|
+
# Offense count: 1
|
374
|
+
# Cop supports --auto-correct.
|
375
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
376
|
+
Lint/UnusedMethodArgument:
|
377
|
+
Exclude:
|
378
|
+
- 'lib/reform/form/active_model/validations.rb'
|
379
|
+
|
380
|
+
# Offense count: 1
|
381
|
+
Lint/UselessAssignment:
|
382
|
+
Exclude:
|
383
|
+
- 'test/unique_test.rb'
|
384
|
+
|
385
|
+
# Offense count: 1
|
386
|
+
Metrics/AbcSize:
|
387
|
+
Max: 26
|
388
|
+
|
389
|
+
# Offense count: 1
|
390
|
+
# Configuration parameters: CountComments.
|
391
|
+
Metrics/ClassLength:
|
392
|
+
Max: 152
|
393
|
+
|
394
|
+
# Offense count: 23
|
395
|
+
# Cop supports --auto-correct.
|
396
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
397
|
+
# URISchemes: http, https
|
398
|
+
Metrics/LineLength:
|
399
|
+
Max: 262
|
400
|
+
|
401
|
+
# Offense count: 1
|
402
|
+
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
|
403
|
+
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
|
404
|
+
Naming/MemoizedInstanceVariableName:
|
405
|
+
Exclude:
|
406
|
+
- 'lib/reform/form/active_model/validations.rb'
|
407
|
+
|
408
|
+
# Offense count: 2
|
409
|
+
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
|
410
|
+
# NamePrefix: is_, has_, have_
|
411
|
+
# NamePrefixBlacklist: is_, has_, have_
|
412
|
+
# NameWhitelist: is_a?
|
413
|
+
# MethodDefinitionMacros: define_method, define_singleton_method
|
414
|
+
Naming/PredicateName:
|
415
|
+
Exclude:
|
416
|
+
- 'spec/**/*'
|
417
|
+
- 'lib/reform/form/active_model/model_reflections.rb'
|
418
|
+
- 'test/model_reflections_test.rb'
|
419
|
+
|
420
|
+
# Offense count: 6
|
421
|
+
# Configuration parameters: EnforcedStyle.
|
422
|
+
# SupportedStyles: snake_case, normalcase, non_integer
|
423
|
+
Naming/VariableNumber:
|
424
|
+
Exclude:
|
425
|
+
- 'test/unique_test.rb'
|
426
|
+
|
427
|
+
# Offense count: 9
|
428
|
+
# Cop supports --auto-correct.
|
429
|
+
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners.
|
430
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
431
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
432
|
+
# FunctionalMethods: let, let!, subject, watch
|
433
|
+
# IgnoredMethods: lambda, proc, it
|
434
|
+
Style/BlockDelimiters:
|
435
|
+
Exclude:
|
436
|
+
- 'test/active_model_test.rb'
|
437
|
+
- 'test/active_record_test.rb'
|
438
|
+
- 'test/form_builder_test.rb'
|
439
|
+
- 'test/mongoid_test.rb'
|
440
|
+
|
441
|
+
# Offense count: 21
|
442
|
+
# Cop supports --auto-correct.
|
443
|
+
# Configuration parameters: EnforcedStyle.
|
444
|
+
# SupportedStyles: braces, no_braces, context_dependent
|
445
|
+
Style/BracesAroundHashParameters:
|
446
|
+
Exclude:
|
447
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
448
|
+
- 'test/active_model_validation_for_property_named_format_test.rb'
|
449
|
+
- 'test/active_record_test.rb'
|
450
|
+
- 'test/activemodel_validation_test.rb'
|
451
|
+
- 'test/form_test.rb'
|
452
|
+
- 'test/mongoid_test.rb'
|
453
|
+
- 'test/unique_test.rb'
|
454
|
+
|
455
|
+
# Offense count: 8
|
456
|
+
Style/CommentedKeyword:
|
457
|
+
Exclude:
|
458
|
+
- 'lib/reform/form/active_model.rb'
|
459
|
+
- 'lib/reform/form/active_model/validations.rb'
|
460
|
+
- 'lib/reform/rails/railtie.rb'
|
461
|
+
- 'test/active_model_test.rb'
|
462
|
+
- 'test/activemodel_validation_test.rb'
|
463
|
+
|
464
|
+
# Offense count: 1
|
465
|
+
# Cop supports --auto-correct.
|
466
|
+
Style/Encoding:
|
467
|
+
Exclude:
|
468
|
+
- 'reform-rails.gemspec'
|
469
|
+
|
470
|
+
# Offense count: 1
|
471
|
+
# Cop supports --auto-correct.
|
472
|
+
Style/ExpandPathArguments:
|
473
|
+
Exclude:
|
474
|
+
- 'reform-rails.gemspec'
|
475
|
+
|
476
|
+
# Offense count: 2
|
477
|
+
# Configuration parameters: MinBodyLength.
|
478
|
+
Style/GuardClause:
|
479
|
+
Exclude:
|
480
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
481
|
+
- 'test/custom_validation_test.rb'
|
482
|
+
|
483
|
+
# Offense count: 2
|
484
|
+
Style/IdenticalConditionalBranches:
|
485
|
+
Exclude:
|
486
|
+
- 'lib/reform/form/active_model.rb'
|
487
|
+
|
488
|
+
# Offense count: 1
|
489
|
+
# Configuration parameters: AllowIfModifier.
|
490
|
+
Style/IfInsideElse:
|
491
|
+
Exclude:
|
492
|
+
- 'lib/reform/form/active_model.rb'
|
493
|
+
|
494
|
+
# Offense count: 7
|
495
|
+
# Cop supports --auto-correct.
|
496
|
+
Style/IfUnlessModifier:
|
497
|
+
Exclude:
|
498
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
499
|
+
- 'lib/reform/form/multi_parameter_attributes.rb'
|
500
|
+
- 'lib/reform/form/validation/unique_validator.rb'
|
501
|
+
- 'test/activemodel_validation_test.rb'
|
502
|
+
- 'test/custom_validation_test.rb'
|
503
|
+
|
504
|
+
# Offense count: 1
|
505
|
+
Style/ImplicitRuntimeError:
|
506
|
+
Exclude:
|
507
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
508
|
+
|
509
|
+
# Offense count: 2
|
510
|
+
# Cop supports --auto-correct.
|
511
|
+
# Configuration parameters: EnforcedStyle.
|
512
|
+
# SupportedStyles: line_count_dependent, lambda, literal
|
513
|
+
Style/Lambda:
|
514
|
+
Exclude:
|
515
|
+
- 'test/activemodel_validation_test.rb'
|
516
|
+
|
517
|
+
# Offense count: 2
|
518
|
+
Style/MethodCalledOnDoEndBlock:
|
519
|
+
Exclude:
|
520
|
+
- 'test/active_record_test.rb'
|
521
|
+
- 'test/mongoid_test.rb'
|
522
|
+
|
523
|
+
# Offense count: 3
|
524
|
+
# Cop supports --auto-correct.
|
525
|
+
# Configuration parameters: EnforcedStyle.
|
526
|
+
# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
|
527
|
+
Style/MethodDefParentheses:
|
528
|
+
Exclude:
|
529
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
530
|
+
- 'test/custom_validation_test.rb'
|
531
|
+
|
532
|
+
# Offense count: 2
|
533
|
+
Style/MethodMissingSuper:
|
534
|
+
Exclude:
|
535
|
+
- 'lib/reform/form/active_model/validations.rb'
|
536
|
+
|
537
|
+
# Offense count: 1
|
538
|
+
# Configuration parameters: EnforcedStyle.
|
539
|
+
# SupportedStyles: if, case, both
|
540
|
+
Style/MissingElse:
|
541
|
+
Exclude:
|
542
|
+
- 'Gemfile'
|
543
|
+
|
544
|
+
# Offense count: 2
|
545
|
+
Style/MissingRespondToMissing:
|
546
|
+
Exclude:
|
547
|
+
- 'lib/reform/form/active_model/validations.rb'
|
548
|
+
|
549
|
+
# Offense count: 1
|
550
|
+
Style/MultilineTernaryOperator:
|
551
|
+
Exclude:
|
552
|
+
- 'lib/reform/form/multi_parameter_attributes.rb'
|
553
|
+
|
554
|
+
# Offense count: 1
|
555
|
+
# Cop supports --auto-correct.
|
556
|
+
# Configuration parameters: EnforcedStyle.
|
557
|
+
# SupportedStyles: literals, strict
|
558
|
+
Style/MutableConstant:
|
559
|
+
Exclude:
|
560
|
+
- 'lib/reform/rails/version.rb'
|
561
|
+
|
562
|
+
# Offense count: 5
|
563
|
+
# Cop supports --auto-correct.
|
564
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
565
|
+
# SupportedStyles: predicate, comparison
|
566
|
+
Style/NumericPredicate:
|
567
|
+
Exclude:
|
568
|
+
- 'spec/**/*'
|
569
|
+
- 'lib/reform/form/validation/unique_validator.rb'
|
570
|
+
- 'test/active_record_test.rb'
|
571
|
+
- 'test/mongoid_test.rb'
|
572
|
+
|
573
|
+
# Offense count: 3
|
574
|
+
# Configuration parameters: SuspiciousParamNames.
|
575
|
+
# SuspiciousParamNames: options, opts, args, params, parameters
|
576
|
+
Style/OptionHash:
|
577
|
+
Exclude:
|
578
|
+
- 'lib/reform/form/active_model.rb'
|
579
|
+
- 'lib/reform/form/active_record.rb'
|
580
|
+
- 'lib/reform/form/mongoid.rb'
|
581
|
+
|
582
|
+
# Offense count: 3
|
583
|
+
# Cop supports --auto-correct.
|
584
|
+
# Configuration parameters: PreferredDelimiters.
|
585
|
+
Style/PercentLiteralDelimiters:
|
586
|
+
Exclude:
|
587
|
+
- 'reform-rails.gemspec'
|
588
|
+
- 'test/form_builder_test.rb'
|
589
|
+
|
590
|
+
# Offense count: 3
|
591
|
+
# Cop supports --auto-correct.
|
592
|
+
# Configuration parameters: EnforcedStyle.
|
593
|
+
# SupportedStyles: short, verbose
|
594
|
+
Style/PreferredHashMethods:
|
595
|
+
Exclude:
|
596
|
+
- 'lib/reform/form/active_model/form_builder_methods.rb'
|
597
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
598
|
+
|
599
|
+
# Offense count: 1
|
600
|
+
# Cop supports --auto-correct.
|
601
|
+
Style/RedundantInterpolation:
|
602
|
+
Exclude:
|
603
|
+
- 'test/active_model_test.rb'
|
604
|
+
|
605
|
+
# Offense count: 2
|
606
|
+
# Cop supports --auto-correct.
|
607
|
+
Style/RedundantPercentQ:
|
608
|
+
Exclude:
|
609
|
+
- 'reform-rails.gemspec'
|
610
|
+
|
611
|
+
# Offense count: 1
|
612
|
+
# Cop supports --auto-correct.
|
613
|
+
# Configuration parameters: EnforcedStyle.
|
614
|
+
# SupportedStyles: return, return_nil
|
615
|
+
Style/ReturnNil:
|
616
|
+
Exclude:
|
617
|
+
- 'lib/reform/form/multi_parameter_attributes.rb'
|
618
|
+
|
619
|
+
# Offense count: 7
|
620
|
+
Style/Send:
|
621
|
+
Exclude:
|
622
|
+
- 'lib/reform/form/active_model/model_reflections.rb'
|
623
|
+
- 'lib/reform/form/active_model/validations.rb'
|
624
|
+
- 'lib/reform/form/orm.rb'
|
625
|
+
- 'lib/reform/form/validation/unique_validator.rb'
|
626
|
+
|
627
|
+
# Offense count: 1
|
628
|
+
# Cop supports --auto-correct.
|
629
|
+
# Configuration parameters: EnforcedStyle.
|
630
|
+
# SupportedStyles: only_raise, only_fail, semantic
|
631
|
+
Style/SignalException:
|
632
|
+
Exclude:
|
633
|
+
- 'lib/reform/form/active_model/model_validations.rb'
|
634
|
+
|
635
|
+
# Offense count: 133
|
636
|
+
# Cop supports --auto-correct.
|
637
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
638
|
+
# SupportedStyles: single_quotes, double_quotes
|
639
|
+
Style/StringLiterals:
|
640
|
+
Enabled: false
|
641
|
+
|
642
|
+
# Offense count: 4
|
643
|
+
# Cop supports --auto-correct.
|
644
|
+
# Configuration parameters: MinSize.
|
645
|
+
# SupportedStyles: percent, brackets
|
646
|
+
Style/SymbolArray:
|
647
|
+
EnforcedStyle: brackets
|
648
|
+
|
649
|
+
# Offense count: 2
|
650
|
+
# Cop supports --auto-correct.
|
651
|
+
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
|
652
|
+
# SupportedStyles: percent, brackets
|
653
|
+
Style/WordArray:
|
654
|
+
Exclude:
|
655
|
+
- 'test/activemodel_validation_test.rb'
|
656
|
+
|
657
|
+
# Offense count: 2
|
658
|
+
# Cop supports --auto-correct.
|
659
|
+
Style/ZeroLengthPredicate:
|
660
|
+
Exclude:
|
661
|
+
- 'test/mongoid_test.rb'
|
data/.travis.yml
CHANGED
@@ -1,27 +1,19 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
|
-
|
3
|
+
before_install:
|
4
|
+
- gem update --system
|
5
|
+
- gem install bundler
|
4
6
|
rvm:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
- 2.4.0
|
7
|
+
- 2.5.5
|
8
|
+
- 2.6.3
|
9
|
+
- 2.7
|
9
10
|
services:
|
10
11
|
- mongodb
|
11
12
|
env:
|
12
|
-
- "RAILS_VERSION=
|
13
|
-
- "RAILS_VERSION=
|
14
|
-
- "RAILS_VERSION=
|
15
|
-
- "RAILS_VERSION=
|
13
|
+
- "RAILS_VERSION=6.1.0"
|
14
|
+
- "RAILS_VERSION=6.0.0"
|
15
|
+
- "RAILS_VERSION=5.2.0"
|
16
|
+
- "RAILS_VERSION=5.1.0"
|
16
17
|
- "RAILS_VERSION=5.0.0"
|
17
18
|
matrix:
|
18
19
|
fast_finish: true
|
19
|
-
exclude:
|
20
|
-
- rvm: 2.1.10
|
21
|
-
env: "RAILS_VERSION=5.0.0"
|
22
|
-
- rvm: 2.4.0
|
23
|
-
env: "RAILS_VERSION=3.2.0"
|
24
|
-
- rvm: 2.4.0
|
25
|
-
env: "RAILS_VERSION=4.0.0"
|
26
|
-
- rvm: 2.4.0
|
27
|
-
env: "RAILS_VERSION=4.1.0"
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 0.2.2
|
2
|
+
|
3
|
+
* Support ActiveRecord 6.1
|
4
|
+
|
5
|
+
# 0.2.1
|
6
|
+
|
7
|
+
* Error's full_message with translation fixed thanks to [@marcelolx](https://github.com/trailblazer/reform-rails/pull/85)
|
8
|
+
|
1
9
|
# 0.2.0
|
2
10
|
|
3
11
|
* Needs Reform >= 2.3.0.
|
@@ -7,7 +15,14 @@
|
|
7
15
|
* fix bug in uniqueness validation where form has different attribute name to column
|
8
16
|
* improve handling of persisted records in uniqueness validator
|
9
17
|
* remove params.merge! as it's deprecated in rails 5
|
10
|
-
* update to support reform 2.3, the new API means that `errors.add` is delegated to ActiveModel::Errors
|
18
|
+
* update to support reform 2.3, the new API means that `errors.add` is delegated to ActiveModel::Errors to support rails 5
|
19
|
+
* Fix nested form validation (#53)
|
20
|
+
* Errors supports symbol and string lookup (PR #77)
|
21
|
+
* Implement respond_to that delegates to AMV errors (PR #78)
|
22
|
+
* Drop support for activemodel before 5.0
|
23
|
+
|
24
|
+
# 0.1.8
|
25
|
+
* Drop support to mongoid < 4.
|
11
26
|
|
12
27
|
# 0.1.7 (0.1.6 Yanked)
|
13
28
|
|
data/Gemfile
CHANGED
@@ -1,17 +1,33 @@
|
|
1
|
-
|
1
|
+
git_source(:github) do |repo_name|
|
2
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
3
|
+
"https://github.com/#{repo_name}.git"
|
4
|
+
end
|
2
5
|
|
3
|
-
|
6
|
+
source "https://rubygems.org"
|
4
7
|
gemspec
|
5
8
|
|
6
|
-
|
7
|
-
|
9
|
+
gem 'pry-byebug'
|
10
|
+
gem "minitest-line"
|
11
|
+
|
12
|
+
case ENV["GEMS_SOURCE"]
|
13
|
+
when "local"
|
14
|
+
gem "reform", path: "../reform"
|
15
|
+
when "github"
|
16
|
+
gem "reform", github: "trailblazer/reform"
|
17
|
+
end
|
8
18
|
|
9
|
-
rails_version = ENV
|
19
|
+
rails_version = ENV.fetch("RAILS_VERSION", "6.0.0")
|
10
20
|
|
11
21
|
# bored of wrestling with rails...
|
12
|
-
if rails_version == '4.0'
|
13
|
-
gem 'mongoid', '~> 4'
|
14
|
-
end
|
15
22
|
|
16
|
-
gem
|
23
|
+
gem("mongoid", "< 7.0") unless rails_version.to_i >= 6
|
24
|
+
|
25
|
+
|
17
26
|
gem "activerecord", "~> #{rails_version}"
|
27
|
+
gem "railties", "~> #{rails_version}"
|
28
|
+
if rails_version.to_i >= 6
|
29
|
+
gem "sqlite3", "~> 1.4"
|
30
|
+
else
|
31
|
+
gem "sqlite3", "~> 1.3", "< 1.4"
|
32
|
+
end
|
33
|
+
puts "Rails version #{rails_version}"
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Simply don't include this gem if you don't want to use the conventional Reform/R
|
|
14
14
|
|
15
15
|
## Documentation
|
16
16
|
|
17
|
-
The [full documentation](
|
17
|
+
The [full documentation](https://trailblazer.to/2.0/gems/reform/rails.html) can be found on the Trailblazer page.
|
18
18
|
|
19
19
|
## Installation
|
20
20
|
|
@@ -24,16 +24,16 @@ Add this line to your application's Gemfile:
|
|
24
24
|
gem 'reform-rails'
|
25
25
|
```
|
26
26
|
|
27
|
-
Reform-rails needs Reform >= 2.
|
27
|
+
Reform-rails needs Reform >= 2.3.
|
28
28
|
|
29
29
|
## Contributing
|
30
30
|
|
31
|
-
By default your tests will run against rails
|
31
|
+
By default your tests will run against rails 6.0.1.
|
32
32
|
Please ensure that you test your changes against all supported ruby and rails versions (see .travis.yml)
|
33
33
|
|
34
34
|
You can run tests for a specific version of rails by running the following:
|
35
35
|
|
36
|
-
`export RAILS_VERSION=
|
36
|
+
`export RAILS_VERSION=5.0.0; bundle update; bundle exec rake test`
|
37
37
|
|
38
38
|
## License
|
39
39
|
|
data/lib/reform/active_record.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require "reform/form/active_model"
|
2
1
|
require "reform/form/orm"
|
2
|
+
require "reform/form/active_model"
|
3
3
|
require "reform/form/active_record"
|
4
4
|
require "reform/form/active_model/model_reflections" # only load this in AR context as simple_form currently is bound to AR.
|
5
|
+
require "reform/form/active_model/result"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Reform::Contract::Result
|
2
|
+
private
|
3
|
+
|
4
|
+
def filter_for(method, *args)
|
5
|
+
@results.collect { |r| r.public_send(method, *args).to_h }
|
6
|
+
.inject({}) { |hah, err| hah.merge(err) { |key, old_v, new_v| (new_v.is_a?(Array) ? (old_v |= new_v) : old_v.merge(new_v)) } }
|
7
|
+
.find_all { |k, v| # filter :nested=>{:something=>["too nested!"]} #DISCUSS: do we want that here?
|
8
|
+
if v.is_a?(Hash)
|
9
|
+
nested_errors = v.select { |attr_key, val| attr_key.is_a?(Integer) && val.is_a?(Array) && val.any? }
|
10
|
+
v = nested_errors.to_a if nested_errors.any?
|
11
|
+
end
|
12
|
+
v.is_a?(Array) || v.class.to_s == "ActiveModel::DeprecationHandlingMessageArray"
|
13
|
+
}.to_h
|
14
|
+
end
|
15
|
+
end
|
@@ -52,16 +52,29 @@ module Reform
|
|
52
52
|
@amv_errors
|
53
53
|
end
|
54
54
|
|
55
|
+
def custom_errors
|
56
|
+
# required to keep update the ActiveModel::Errors#details used to test for
|
57
|
+
# added errors ActiveModel::Errors#added? and needs to be inside this block!
|
58
|
+
super.each do |custom_error|
|
59
|
+
errors = custom_error.errors
|
60
|
+
# CustomError build always the errors with an hash where the value is an array
|
61
|
+
errors.values.first.each do |value|
|
62
|
+
@amv_errors.add(errors.keys.first, value)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
55
67
|
def validate!(params, pointers=[])
|
56
68
|
@amv_errors = ActiveModel::Errors.new(self)
|
57
69
|
|
58
70
|
super.tap do
|
59
71
|
# @fran: super ugly hack thanks to the shit architecture of AMV. let's drop it in 3.0 and move on!
|
60
|
-
all_errors = @result.
|
72
|
+
all_errors = @result.to_results
|
73
|
+
nested_errors = @result.instance_variable_get(:@failure)
|
61
74
|
|
62
|
-
@result = Reform::Contract::Result.new(all_errors)
|
75
|
+
@result = Reform::Contract::Result.new(all_errors, [nested_errors].compact)
|
63
76
|
|
64
|
-
@amv_errors = Result::ResultErrors.new(@result, self, @result.success
|
77
|
+
@amv_errors = Result::ResultErrors.new(@result, self, @result.success?, @amv_errors)
|
65
78
|
end
|
66
79
|
@result
|
67
80
|
end
|
@@ -109,9 +122,10 @@ module Reform
|
|
109
122
|
end
|
110
123
|
|
111
124
|
class ResultErrors < ::Reform::Contract::Result::Errors # to expose via #errors. i hate it.
|
112
|
-
def initialize(a, b, success)
|
125
|
+
def initialize(a, b, success, amv_errors)
|
113
126
|
super(a, b)
|
114
127
|
@success = success
|
128
|
+
@amv_errors = amv_errors
|
115
129
|
end
|
116
130
|
|
117
131
|
def empty?
|
@@ -119,13 +133,67 @@ module Reform
|
|
119
133
|
end
|
120
134
|
|
121
135
|
def [](k)
|
122
|
-
super || []
|
136
|
+
super(k.to_sym) || []
|
123
137
|
end
|
124
138
|
|
125
139
|
# rails expects this to return a stringified hash of the messages
|
126
140
|
def to_s
|
127
141
|
messages.to_s
|
128
142
|
end
|
143
|
+
|
144
|
+
def add(key, error_text)
|
145
|
+
# use rails magic to get the correct error_text and make sure we still update details and fields
|
146
|
+
error = @amv_errors.add(key, error_text)
|
147
|
+
error = [error.message] unless error.is_a?(Array)
|
148
|
+
|
149
|
+
# using error_text instead of text to either keep the symbol which will be
|
150
|
+
# magically replaced with the translate or directly the string - this is also
|
151
|
+
# required otherwise in the custom_errors method we will add the actual message in the
|
152
|
+
# ActiveModel::Errors#details which is not correct if a symbol was passed here
|
153
|
+
Reform::Contract::CustomError.new(key, error_text, @result.to_results)
|
154
|
+
|
155
|
+
# but since messages method is actually already defined in `Reform::Contract::Result::Errors
|
156
|
+
# we need to update the @dotted_errors instance variable to add or merge a new error
|
157
|
+
@dotted_errors.key?(key) ? @dotted_errors[key] |= error : @dotted_errors[key] = error
|
158
|
+
instance_variable_set(:@dotted_errors, @dotted_errors)
|
159
|
+
end
|
160
|
+
|
161
|
+
def method_missing(m, *args, &block)
|
162
|
+
@amv_errors.send(m, *args, &block) # send all methods to the AMV errors, even privates.
|
163
|
+
end
|
164
|
+
|
165
|
+
def respond_to?(method)
|
166
|
+
@amv_errors.respond_to?(method) ? true : super
|
167
|
+
end
|
168
|
+
|
169
|
+
def full_messages
|
170
|
+
base_errors = @amv_errors.full_messages
|
171
|
+
form_fields = @amv_errors.instance_variable_get(:@base).instance_variable_get(:@fields)
|
172
|
+
nested_errors = full_messages_for_nested_fields(form_fields)
|
173
|
+
|
174
|
+
[base_errors, nested_errors].flatten.compact
|
175
|
+
end
|
176
|
+
|
177
|
+
private
|
178
|
+
|
179
|
+
def full_messages_for_nested_fields(form_fields)
|
180
|
+
form_fields.map { |field| full_messages_for_twin(field[1]) }
|
181
|
+
end
|
182
|
+
|
183
|
+
def full_messages_for_twin(object)
|
184
|
+
return get_collection_errors(object) if object.is_a? Disposable::Twin::Collection
|
185
|
+
return get_amv_errors(object) if object.is_a? Disposable::Twin
|
186
|
+
|
187
|
+
nil
|
188
|
+
end
|
189
|
+
|
190
|
+
def get_collection_errors(twin_collection)
|
191
|
+
twin_collection.map { |twin| get_amv_errors(twin) }
|
192
|
+
end
|
193
|
+
|
194
|
+
def get_amv_errors(object)
|
195
|
+
object.instance_variable_get(:@amv_errors).full_messages
|
196
|
+
end
|
129
197
|
end
|
130
198
|
end
|
131
199
|
|
data/lib/reform/form/mongoid.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
gem 'mongoid', ">= 4.0"
|
2
|
+
|
1
3
|
module Reform::Form::Mongoid
|
2
4
|
def self.included(base)
|
3
5
|
base.class_eval do
|
@@ -18,20 +20,7 @@ module Reform::Form::Mongoid
|
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
def self.mongoid_namespace
|
23
|
-
if mongoid_is_4_or_more?
|
24
|
-
'Validatable'
|
25
|
-
else
|
26
|
-
'Validations'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.mongoid_is_4_or_more?
|
31
|
-
Mongoid::VERSION.split('.').first.to_i >= 4
|
32
|
-
end
|
33
|
-
|
34
|
-
UniquenessValidator = Class.new("::Mongoid::#{mongoid_namespace}::UniquenessValidator".constantize) do
|
23
|
+
UniquenessValidator = Class.new("::Mongoid::Validatable::UniquenessValidator".constantize) do
|
35
24
|
include Reform::Form::ORM::UniquenessValidator
|
36
25
|
end
|
37
26
|
end
|
data/lib/reform/form/orm.rb
CHANGED
@@ -19,7 +19,10 @@ module Reform::Form::ORM
|
|
19
19
|
|
20
20
|
@klass = record.class # this is usually done in the super-sucky #setup method.
|
21
21
|
super(record).tap do |res|
|
22
|
-
|
22
|
+
if record.errors.present?
|
23
|
+
error = self.class.name.include?("Mongoid") ? record.errors.first.last : :taken
|
24
|
+
form.errors.add(property, error)
|
25
|
+
end
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
data/lib/reform/mongoid.rb
CHANGED
data/lib/reform/rails.rb
CHANGED
data/lib/reform/rails/railtie.rb
CHANGED
@@ -6,7 +6,6 @@ module Reform
|
|
6
6
|
initializer "reform.form_extensions", after: :load_config_initializers do
|
7
7
|
validations = config.reform.validations || :active_model
|
8
8
|
|
9
|
-
require "reform"
|
10
9
|
require "reform/form/multi_parameter_attributes"
|
11
10
|
|
12
11
|
if validations == :active_model
|
@@ -27,14 +26,14 @@ module Reform
|
|
27
26
|
require "reform/form/active_model/model_validations"
|
28
27
|
require "reform/form/active_model/validations"
|
29
28
|
|
30
|
-
require "reform/active_record" if defined?(ActiveRecord)
|
31
|
-
require "reform/mongoid" if defined?(Mongoid)
|
29
|
+
require "reform/active_record" if defined?(::ActiveRecord)
|
30
|
+
require "reform/mongoid" if defined?(::Mongoid)
|
32
31
|
|
33
32
|
Reform::Form.class_eval do
|
34
33
|
include Reform::Form::ActiveModel
|
35
34
|
include Reform::Form::ActiveModel::FormBuilderMethods
|
36
|
-
include Reform::Form::ActiveRecord if defined?(ActiveRecord)
|
37
|
-
include Reform::Form::Mongoid if defined?(Mongoid)
|
35
|
+
include Reform::Form::ActiveRecord if defined?(::ActiveRecord)
|
36
|
+
include Reform::Form::Mongoid if defined?(::Mongoid)
|
38
37
|
include Reform::Form::ActiveModel::Validations
|
39
38
|
end
|
40
39
|
end
|
data/lib/reform/rails/version.rb
CHANGED
data/reform-rails.gemspec
CHANGED
@@ -14,19 +14,12 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/trailblazer/reform-rails"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test/|spec/|features/|database.sqlite3)})
|
19
|
+
end
|
18
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
21
|
spec.require_paths = ["lib"]
|
20
22
|
|
21
|
-
spec.add_dependency "reform", ">= 2.3.
|
22
|
-
spec.add_dependency "activemodel", ">=
|
23
|
-
|
24
|
-
spec.add_development_dependency "rails"
|
25
|
-
spec.add_development_dependency "bundler"
|
26
|
-
spec.add_development_dependency "rake"
|
27
|
-
spec.add_development_dependency "minitest"
|
28
|
-
spec.add_development_dependency "actionpack"
|
29
|
-
spec.add_development_dependency "activerecord"
|
30
|
-
spec.add_development_dependency "mongoid"
|
31
|
-
spec.add_development_dependency "sqlite3"
|
23
|
+
spec.add_dependency "reform", ">= 2.3.1", "< 3.0.0"
|
24
|
+
spec.add_dependency "activemodel", ">= 5.0"
|
32
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reform-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reform
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.3.
|
19
|
+
version: 2.3.1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 3.0.0
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.3.
|
29
|
+
version: 2.3.1
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.0.0
|
@@ -36,126 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '5.0'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rails
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: bundler
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: rake
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - ">="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: minitest
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - ">="
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '0'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: actionpack
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - ">="
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - ">="
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '0'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: activerecord
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - ">="
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '0'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - ">="
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '0'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: mongoid
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - ">="
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '0'
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - ">="
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '0'
|
145
|
-
- !ruby/object:Gem::Dependency
|
146
|
-
name: sqlite3
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - ">="
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '0'
|
152
|
-
type: :development
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
requirements:
|
156
|
-
- - ">="
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '0'
|
46
|
+
version: '5.0'
|
159
47
|
description: Automatically load and include all common Reform features for a standard
|
160
48
|
Rails environment.
|
161
49
|
email:
|
@@ -165,18 +53,20 @@ extensions: []
|
|
165
53
|
extra_rdoc_files: []
|
166
54
|
files:
|
167
55
|
- ".gitignore"
|
56
|
+
- ".rubocop.yml"
|
57
|
+
- ".rubocop_todo.yml"
|
168
58
|
- ".travis.yml"
|
169
59
|
- CHANGES.md
|
170
60
|
- Gemfile
|
171
61
|
- LICENSE.txt
|
172
62
|
- README.md
|
173
63
|
- Rakefile
|
174
|
-
- database.sqlite3
|
175
64
|
- lib/reform/active_record.rb
|
176
65
|
- lib/reform/form/active_model.rb
|
177
66
|
- lib/reform/form/active_model/form_builder_methods.rb
|
178
67
|
- lib/reform/form/active_model/model_reflections.rb
|
179
68
|
- lib/reform/form/active_model/model_validations.rb
|
69
|
+
- lib/reform/form/active_model/result.rb
|
180
70
|
- lib/reform/form/active_model/validations.rb
|
181
71
|
- lib/reform/form/active_record.rb
|
182
72
|
- lib/reform/form/mongoid.rb
|
@@ -192,7 +82,7 @@ homepage: https://github.com/trailblazer/reform-rails
|
|
192
82
|
licenses:
|
193
83
|
- MIT
|
194
84
|
metadata: {}
|
195
|
-
post_install_message:
|
85
|
+
post_install_message:
|
196
86
|
rdoc_options: []
|
197
87
|
require_paths:
|
198
88
|
- lib
|
@@ -203,13 +93,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
203
93
|
version: '0'
|
204
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
95
|
requirements:
|
206
|
-
- - "
|
96
|
+
- - ">="
|
207
97
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
98
|
+
version: '0'
|
209
99
|
requirements: []
|
210
|
-
|
211
|
-
|
212
|
-
signing_key:
|
100
|
+
rubygems_version: 3.2.3
|
101
|
+
signing_key:
|
213
102
|
specification_version: 4
|
214
103
|
summary: Automatically load and include all common Rails form features.
|
215
104
|
test_files: []
|
data/database.sqlite3
DELETED
Binary file
|