researchable-freedcamp-api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bundle/config +2 -0
- data/.gitignore +1 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +69 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/researchable/freedcamp_api/create_task.rb +22 -0
- data/lib/researchable/freedcamp_api/endpoint.rb +34 -0
- data/lib/researchable/freedcamp_api/list_milestones.rb +1 -0
- data/lib/researchable/freedcamp_api/list_projects.rb +1 -0
- data/lib/researchable/freedcamp_api/list_tasks.rb +36 -0
- data/lib/researchable/freedcamp_api/sessions/session.rb +28 -0
- data/lib/researchable/freedcamp_api/sessions/signed_session.rb +128 -0
- data/lib/researchable/freedcamp_api/sessions.rb +17 -0
- data/lib/researchable/freedcamp_api/structs/signature.rb +11 -0
- data/lib/researchable/freedcamp_api/structs/task.rb +48 -0
- data/lib/researchable/freedcamp_api/structs.rb +8 -0
- data/lib/researchable/freedcamp_api/update_task.rb +27 -0
- data/lib/researchable/freedcamp_api/version.rb +8 -0
- data/lib/researchable/freedcamp_api.rb +21 -0
- data/lib/researchable-freedcamp-api.rb +6 -0
- data/output/62d1c67bf1eebc3456f9cc8879519700b2a0fc45 +1 -0
- data/researchable_freedcamp_api.gemspec +44 -0
- data/sorbet/config +3 -0
- data/sorbet/rbi/gems/active_interaction.rbi +304 -0
- data/sorbet/rbi/gems/activemodel.rbi +342 -0
- data/sorbet/rbi/gems/activesupport.rbi +1023 -0
- data/sorbet/rbi/gems/concurrent-ruby.rbi +1662 -0
- data/sorbet/rbi/gems/httparty.rbi +446 -0
- data/sorbet/rbi/gems/i18n.rbi +133 -0
- data/sorbet/rbi/gems/mime-types-data.rbi +17 -0
- data/sorbet/rbi/gems/mime-types.rbi +225 -0
- data/sorbet/rbi/gems/multi_xml.rbi +35 -0
- data/sorbet/rbi/gems/researchable-freedcamp-api.rbi +25 -0
- data/sorbet/rbi/gems/rspec-core.rbi +1915 -0
- data/sorbet/rbi/gems/rspec-expectations.rbi +1151 -0
- data/sorbet/rbi/gems/rspec-mocks.rbi +1110 -0
- data/sorbet/rbi/gems/rspec-support.rbi +280 -0
- data/sorbet/rbi/gems/rspec.rbi +15 -0
- data/sorbet/rbi/gems/tzinfo.rbi +586 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +4251 -0
- data/sorbet/rbi/hidden-definitions/hidden.rbi +8306 -0
- data/sorbet/rbi/sorbet-typed/lib/activemodel/all/activemodel.rbi +715 -0
- data/sorbet/rbi/sorbet-typed/lib/activesupport/>=6/activesupport.rbi +37 -0
- data/sorbet/rbi/sorbet-typed/lib/activesupport/all/activesupport.rbi +1850 -0
- data/sorbet/rbi/sorbet-typed/lib/httparty/all/httparty.rbi +566 -0
- data/sorbet/rbi/sorbet-typed/lib/minitest/all/minitest.rbi +108 -0
- data/sorbet/rbi/sorbet-typed/lib/rspec-core/all/rspec-core.rbi +24 -0
- data/sorbet/rbi/todo.rbi +7 -0
- data/test.rb +41 -0
- metadata +198 -0
@@ -0,0 +1,715 @@
|
|
1
|
+
# This file is autogenerated. Do not edit it by hand. Regenerate it with:
|
2
|
+
# srb rbi sorbet-typed
|
3
|
+
#
|
4
|
+
# If you would like to make changes to this file, great! Please upstream any changes you make here:
|
5
|
+
#
|
6
|
+
# https://github.com/sorbet/sorbet-typed/edit/master/lib/activemodel/all/activemodel.rbi
|
7
|
+
#
|
8
|
+
# typed: false
|
9
|
+
|
10
|
+
module ActiveModel::AttributeMethods
|
11
|
+
mixes_in_class_methods(::ActiveModel::AttributeMethods::ClassMethods)
|
12
|
+
end
|
13
|
+
|
14
|
+
module ActiveModel::AttributeMethods::ClassMethods; end
|
15
|
+
|
16
|
+
ActiveModel::AttributeMethods::AttrNames::DEF_SAFE_NAME = T.let(T.unsafe(nil), Regexp)
|
17
|
+
|
18
|
+
ActiveModel::AttributeMethods::CALL_COMPILABLE_REGEXP = T.let(T.unsafe(nil), Regexp)
|
19
|
+
|
20
|
+
ActiveModel::AttributeMethods::NAME_COMPILABLE_REGEXP = T.let(T.unsafe(nil), Regexp)
|
21
|
+
|
22
|
+
module ActiveModel::Conversion
|
23
|
+
mixes_in_class_methods(::ActiveModel::Conversion::ClassMethods)
|
24
|
+
end
|
25
|
+
|
26
|
+
module ActiveModel::Conversion::ClassMethods; end
|
27
|
+
|
28
|
+
module ActiveModel::Dirty
|
29
|
+
include(::ActiveModel::AttributeMethods)
|
30
|
+
|
31
|
+
sig { params(attr: Symbol, from: T.untyped, to: T.untyped).returns(T::Boolean) }
|
32
|
+
def attribute_changed?(attr, from: nil, to: nil); end
|
33
|
+
|
34
|
+
sig { params(attr_name: Symbol).returns(T::Boolean) }
|
35
|
+
def attribute_changed_in_place?(attr_name); end
|
36
|
+
|
37
|
+
sig { params(attr_name: Symbol, options: T.untyped).returns(T::Boolean) }
|
38
|
+
def attribute_previously_changed?(attr_name, **options); end
|
39
|
+
|
40
|
+
sig { returns(T::Boolean) }
|
41
|
+
def changed?; end
|
42
|
+
|
43
|
+
sig { returns(T::Hash[T.any(Symbol, String), T.untyped]) }
|
44
|
+
def previous_changes; end
|
45
|
+
end
|
46
|
+
|
47
|
+
class ActiveModel::ForbiddenAttributesError < ::StandardError
|
48
|
+
end
|
49
|
+
|
50
|
+
module ActiveModel::Model
|
51
|
+
include(::ActiveModel::AttributeAssignment)
|
52
|
+
extend(::ActiveSupport::Concern)
|
53
|
+
|
54
|
+
include(::ActiveSupport::Callbacks)
|
55
|
+
include(::ActiveModel::Validations::HelperMethods)
|
56
|
+
include(::ActiveModel::Validations)
|
57
|
+
include(::ActiveModel::Conversion)
|
58
|
+
end
|
59
|
+
|
60
|
+
module ActiveModel::Validations
|
61
|
+
extend(::ActiveSupport::Concern)
|
62
|
+
|
63
|
+
include(::ActiveSupport::Callbacks)
|
64
|
+
include(::ActiveModel::Validations::HelperMethods)
|
65
|
+
|
66
|
+
mixes_in_class_methods(::ActiveModel::Validations::ClassMethods)
|
67
|
+
|
68
|
+
# Returns the `Errors` object that holds all information about attribute
|
69
|
+
# error messages.
|
70
|
+
#
|
71
|
+
# ```ruby
|
72
|
+
# class Person
|
73
|
+
# include ActiveModel::Validations
|
74
|
+
#
|
75
|
+
# attr_accessor :name
|
76
|
+
# validates_presence_of :name
|
77
|
+
# end
|
78
|
+
#
|
79
|
+
# person = Person.new
|
80
|
+
# person.valid? # => false
|
81
|
+
# person.errors # => #<ActiveModel::Errors:0x007fe603816640 @messages={name:["can't be blank"]}>
|
82
|
+
# ```
|
83
|
+
sig { returns(ActiveModel::Errors) }
|
84
|
+
def errors; end
|
85
|
+
|
86
|
+
sig { params(context: T.untyped).returns(T::Boolean) }
|
87
|
+
def invalid?(context = T.unsafe(nil)); end
|
88
|
+
|
89
|
+
sig { params(context: T.untyped).returns(T::Boolean) }
|
90
|
+
def valid?(context = T.unsafe(nil)); end
|
91
|
+
end
|
92
|
+
|
93
|
+
module ActiveModel::Validations::ClassMethods
|
94
|
+
# https://github.com/rails/rails/blob/v5.2.3/activemodel/lib/active_model/validations.rb#L136-L154
|
95
|
+
sig do
|
96
|
+
params(
|
97
|
+
names: T.any(Symbol, String),
|
98
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
99
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
100
|
+
prepend: T::Boolean,
|
101
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
102
|
+
).void
|
103
|
+
end
|
104
|
+
def validate(
|
105
|
+
*names,
|
106
|
+
if: nil,
|
107
|
+
on: nil,
|
108
|
+
prepend: false,
|
109
|
+
unless: nil
|
110
|
+
); end
|
111
|
+
|
112
|
+
# https://github.com/rails/rails/blob/v5.2.3/activemodel/lib/active_model/validations/validates.rb#L75-L105
|
113
|
+
sig do
|
114
|
+
params(
|
115
|
+
names: T.any(Symbol, String), # a splat of at least one attribute name
|
116
|
+
absence: T.any(T::Boolean, T::Hash[T.untyped, T.untyped]),
|
117
|
+
acceptance: T.any(T::Boolean, T::Hash[T.untyped, T.untyped]),
|
118
|
+
allow_blank: T::Boolean,
|
119
|
+
allow_nil: T::Boolean,
|
120
|
+
confirmation: T.any(T::Boolean, T::Hash[T.untyped, T.untyped]),
|
121
|
+
# `exclusion` and `inclusion` are tricky to type without better support
|
122
|
+
# for overloading and shapes. Value can be anything that responds to
|
123
|
+
# `include?` (e.g. (1..3)), or a hash having an `in` or `within` key,
|
124
|
+
# like { in: [1, 2, 3], ... }
|
125
|
+
exclusion: T::Enumerable[T.untyped],
|
126
|
+
# `format` hash must additionally contain either :with or :without keys.
|
127
|
+
# Alternatively, it can be a Regexp.
|
128
|
+
format: T.any(T::Hash[T.untyped, T.untyped], Regexp),
|
129
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
130
|
+
# `exclusion` and `inclusion` are tricky to type without better support
|
131
|
+
# for overloading and shapes. Value can be anything that responds to
|
132
|
+
# `include?` (e.g. (1..3)), or a hash having an `in` or `within` key,
|
133
|
+
# like { in: [1, 2, 3], ... }
|
134
|
+
inclusion: T::Enumerable[T.untyped],
|
135
|
+
# if Hash, must contain :in, :within, :maximum, :minimum, or :is keys
|
136
|
+
length: T.any(T::Range[T.untyped], T::Hash[T.untyped, T.untyped]),
|
137
|
+
numericality: T.any(T::Boolean, T::Hash[T.untyped, T.untyped]),
|
138
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
139
|
+
presence: T.any(T::Boolean, T::Hash[T.untyped, T.untyped]),
|
140
|
+
size: T.any(T::Boolean, T::Hash[T.untyped, T.untyped]),
|
141
|
+
strict: T::Boolean,
|
142
|
+
uniqueness: T.any(T::Boolean, T::Hash[T.untyped, T.untyped]),
|
143
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
144
|
+
kwargs: T.untyped
|
145
|
+
).void
|
146
|
+
end
|
147
|
+
def validates(
|
148
|
+
*names,
|
149
|
+
absence: false,
|
150
|
+
acceptance: {},
|
151
|
+
allow_blank: false,
|
152
|
+
allow_nil: false,
|
153
|
+
confirmation: false,
|
154
|
+
exclusion: [],
|
155
|
+
format: {},
|
156
|
+
if: nil,
|
157
|
+
inclusion: [],
|
158
|
+
length: {},
|
159
|
+
numericality: false,
|
160
|
+
on: :_,
|
161
|
+
presence: false,
|
162
|
+
size: false,
|
163
|
+
strict: false,
|
164
|
+
uniqueness: false,
|
165
|
+
unless: :_,
|
166
|
+
**kwargs
|
167
|
+
)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
ActiveModel::Validations::ClassMethods::VALID_OPTIONS_FOR_VALIDATE = T.let(T.unsafe(nil), T::Array[T.untyped])
|
172
|
+
|
173
|
+
module ActiveModel::SecurePassword
|
174
|
+
mixes_in_class_methods(::ActiveModel::SecurePassword::ClassMethods)
|
175
|
+
end
|
176
|
+
|
177
|
+
module ActiveModel::SecurePassword::ClassMethods; end
|
178
|
+
|
179
|
+
ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED = T.let(T.unsafe(nil), Integer)
|
180
|
+
|
181
|
+
class ActiveModel::Type::Value
|
182
|
+
extend T::Sig
|
183
|
+
|
184
|
+
sig { params(precision: T.untyped, limit: T.untyped, scale: T.untyped).void }
|
185
|
+
def initialize(precision: nil, limit: nil, scale: nil); end
|
186
|
+
|
187
|
+
sig { params(value: T.untyped).returns(T.untyped) }
|
188
|
+
def cast(value); end
|
189
|
+
end
|
190
|
+
|
191
|
+
class ActiveModel::Type::Boolean < ActiveModel::Type::Value
|
192
|
+
sig { params(arg0: T.untyped).returns(T.nilable(T::Boolean)) }
|
193
|
+
def cast(arg0); end
|
194
|
+
end
|
195
|
+
|
196
|
+
class ActiveModel::Type::ImmutableString < ActiveModel::Type::Value
|
197
|
+
sig { params(arg0: T.untyped).returns(T.nilable(String)) }
|
198
|
+
def cast(arg0); end
|
199
|
+
end
|
200
|
+
class ActiveModel::Type::String < ActiveModel::Type::ImmutableString; end
|
201
|
+
|
202
|
+
class ActiveModel::Type::Integer < ActiveModel::Type::Value
|
203
|
+
sig { params(arg0: T.untyped).returns(T.nilable(Integer)) }
|
204
|
+
def cast(arg0); end
|
205
|
+
end
|
206
|
+
class ActiveModel::Type::BigInteger < ActiveModel::Type::Integer; end
|
207
|
+
|
208
|
+
class ActiveModel::Type::Binary < ActiveModel::Type::Value
|
209
|
+
sig { params(arg0: T.untyped).returns(T.nilable(String)) }
|
210
|
+
def cast(arg0); end
|
211
|
+
end
|
212
|
+
|
213
|
+
class ActiveModel::Type::Decimal < ActiveModel::Type::Value
|
214
|
+
sig { params(arg0: T.untyped).returns(T.nilable(BigDecimal)) }
|
215
|
+
def cast(arg0); end
|
216
|
+
end
|
217
|
+
|
218
|
+
class ActiveModel::Type::Float < ActiveModel::Type::Value
|
219
|
+
sig { params(arg0: T.untyped).returns(T.nilable(Float)) }
|
220
|
+
def cast(arg0); end
|
221
|
+
end
|
222
|
+
|
223
|
+
class ActiveModel::Type::Date < ::ActiveModel::Type::Value
|
224
|
+
sig { params(arg0: T.untyped).returns(T.nilable(Date)) }
|
225
|
+
def cast(arg0); end
|
226
|
+
end
|
227
|
+
|
228
|
+
class ActiveModel::Type::DateTime < ::ActiveModel::Type::Value
|
229
|
+
sig { params(arg0: T.untyped).returns(T.nilable(DateTime)) }
|
230
|
+
def cast(arg0); end
|
231
|
+
end
|
232
|
+
|
233
|
+
module ActiveModel::Validations::Callbacks
|
234
|
+
mixes_in_class_methods(::ActiveModel::Validations::Callbacks::ClassMethods)
|
235
|
+
end
|
236
|
+
|
237
|
+
module ActiveModel::Validations::Callbacks::ClassMethods; end
|
238
|
+
|
239
|
+
module ActiveModel::Validations::HelperMethods
|
240
|
+
# A type alias for the in/within parameters on the
|
241
|
+
# validates_(inclusion/exclusion)_of methods.
|
242
|
+
InWithinType = T.type_alias do
|
243
|
+
T.nilable(
|
244
|
+
T.any(
|
245
|
+
Symbol,
|
246
|
+
String,
|
247
|
+
T::Array[T.any(String, Symbol)],
|
248
|
+
T::Range[Integer],
|
249
|
+
T::Array[T::Boolean],
|
250
|
+
T.proc.params(arg0: T.untyped).returns(T::Boolean)
|
251
|
+
)
|
252
|
+
)
|
253
|
+
end
|
254
|
+
|
255
|
+
module ClassMethods
|
256
|
+
sig do
|
257
|
+
params(
|
258
|
+
attr_names: T.any(String, Symbol),
|
259
|
+
message: String,
|
260
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
261
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
262
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
263
|
+
allow_nil: T::Boolean,
|
264
|
+
allow_blank: T::Boolean,
|
265
|
+
strict: T::Boolean
|
266
|
+
).void
|
267
|
+
end
|
268
|
+
def validates_absence_of(
|
269
|
+
*attr_names,
|
270
|
+
message: 'must be blank',
|
271
|
+
if: nil,
|
272
|
+
unless: :_,
|
273
|
+
on: :_,
|
274
|
+
allow_nil: false,
|
275
|
+
allow_blank: false,
|
276
|
+
strict: false
|
277
|
+
); end
|
278
|
+
|
279
|
+
sig do
|
280
|
+
params(
|
281
|
+
attr_names: T.any(String, Symbol),
|
282
|
+
message: String,
|
283
|
+
accept: T.untyped,
|
284
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
285
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
286
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
287
|
+
allow_nil: T::Boolean,
|
288
|
+
allow_blank: T::Boolean,
|
289
|
+
strict: T::Boolean
|
290
|
+
).void
|
291
|
+
end
|
292
|
+
def validates_acceptance_of(
|
293
|
+
*attr_names,
|
294
|
+
message: 'must be accepted',
|
295
|
+
accept: ['1', true],
|
296
|
+
if: nil,
|
297
|
+
unless: :_,
|
298
|
+
on: :_,
|
299
|
+
allow_nil: false,
|
300
|
+
allow_blank: false,
|
301
|
+
strict: false
|
302
|
+
); end
|
303
|
+
|
304
|
+
sig do
|
305
|
+
params(
|
306
|
+
attr_names: T.any(String, Symbol),
|
307
|
+
message: String,
|
308
|
+
case_sensitive: T::Boolean,
|
309
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
310
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
311
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
312
|
+
allow_nil: T::Boolean,
|
313
|
+
allow_blank: T::Boolean,
|
314
|
+
strict: T::Boolean
|
315
|
+
).void
|
316
|
+
end
|
317
|
+
def validates_confirmation_of(
|
318
|
+
*attr_names,
|
319
|
+
message: "doesn't match %{translated_attribute_name}",
|
320
|
+
case_sensitive: true,
|
321
|
+
if: nil,
|
322
|
+
unless: :_,
|
323
|
+
on: :_,
|
324
|
+
allow_nil: false,
|
325
|
+
allow_blank: false,
|
326
|
+
strict: false
|
327
|
+
); end
|
328
|
+
|
329
|
+
sig do
|
330
|
+
params(
|
331
|
+
attr_names: T.any(String, Symbol),
|
332
|
+
message: String,
|
333
|
+
in: InWithinType,
|
334
|
+
within: InWithinType,
|
335
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
336
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
337
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
338
|
+
allow_nil: T::Boolean,
|
339
|
+
allow_blank: T::Boolean,
|
340
|
+
strict: T::Boolean
|
341
|
+
).void
|
342
|
+
end
|
343
|
+
def validates_exclusion_of(
|
344
|
+
*attr_names,
|
345
|
+
message: 'is reserved',
|
346
|
+
in: nil,
|
347
|
+
within: nil,
|
348
|
+
if: nil,
|
349
|
+
unless: :_,
|
350
|
+
on: :_,
|
351
|
+
allow_nil: false,
|
352
|
+
allow_blank: false,
|
353
|
+
strict: false
|
354
|
+
); end
|
355
|
+
|
356
|
+
sig do
|
357
|
+
params(
|
358
|
+
attr_names: T.any(String, Symbol),
|
359
|
+
message: String,
|
360
|
+
with: T.untyped,
|
361
|
+
without: T.untyped,
|
362
|
+
multiline: T.untyped,
|
363
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
364
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
365
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
366
|
+
allow_nil: T::Boolean,
|
367
|
+
allow_blank: T::Boolean,
|
368
|
+
strict: T::Boolean
|
369
|
+
).void
|
370
|
+
end
|
371
|
+
def validates_format_of(
|
372
|
+
*attr_names,
|
373
|
+
message: 'is invalid',
|
374
|
+
with: nil,
|
375
|
+
without: nil,
|
376
|
+
multiline: nil,
|
377
|
+
if: nil,
|
378
|
+
unless: :_,
|
379
|
+
on: :_,
|
380
|
+
allow_nil: false,
|
381
|
+
allow_blank: false,
|
382
|
+
strict: false
|
383
|
+
); end
|
384
|
+
|
385
|
+
sig do
|
386
|
+
params(
|
387
|
+
attr_names: T.any(String, Symbol),
|
388
|
+
message: String,
|
389
|
+
in: InWithinType,
|
390
|
+
within: InWithinType,
|
391
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
392
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
393
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
394
|
+
allow_nil: T::Boolean,
|
395
|
+
allow_blank: T::Boolean,
|
396
|
+
strict: T::Boolean
|
397
|
+
).void
|
398
|
+
end
|
399
|
+
def validates_inclusion_of(
|
400
|
+
*attr_names,
|
401
|
+
message: 'is not included in the list',
|
402
|
+
in: nil,
|
403
|
+
within: nil,
|
404
|
+
if: nil,
|
405
|
+
unless: :_,
|
406
|
+
on: :_,
|
407
|
+
allow_nil: false,
|
408
|
+
allow_blank: false,
|
409
|
+
strict: false
|
410
|
+
); end
|
411
|
+
|
412
|
+
sig do
|
413
|
+
params(
|
414
|
+
attr_names: T.any(String, Symbol),
|
415
|
+
message: T.nilable(String),
|
416
|
+
minimum: T.nilable(Integer),
|
417
|
+
maximum: T.nilable(Integer),
|
418
|
+
is: T.nilable(Integer),
|
419
|
+
within: T.nilable(T::Range[Integer]),
|
420
|
+
in: T.nilable(T::Range[Integer]),
|
421
|
+
too_long: String,
|
422
|
+
too_short: String,
|
423
|
+
wrong_length: String,
|
424
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
425
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
426
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
427
|
+
allow_nil: T::Boolean,
|
428
|
+
allow_blank: T::Boolean,
|
429
|
+
strict: T::Boolean
|
430
|
+
).void
|
431
|
+
end
|
432
|
+
def validates_length_of(
|
433
|
+
*attr_names,
|
434
|
+
message: nil,
|
435
|
+
minimum: nil,
|
436
|
+
maximum: nil,
|
437
|
+
is: nil,
|
438
|
+
within: nil,
|
439
|
+
in: nil,
|
440
|
+
too_long: 'is too long (maximum is %{count} characters)',
|
441
|
+
too_short: 'is too short (minimum is %{count} characters)',
|
442
|
+
wrong_length: 'is the wrong length (should be %{count} characters)',
|
443
|
+
if: nil,
|
444
|
+
unless: :_,
|
445
|
+
on: :_,
|
446
|
+
allow_nil: false,
|
447
|
+
allow_blank: false,
|
448
|
+
strict: false
|
449
|
+
); end
|
450
|
+
|
451
|
+
# validates_size_of is an alias of validates_length_of
|
452
|
+
sig do
|
453
|
+
params(
|
454
|
+
attr_names: T.any(String, Symbol),
|
455
|
+
message: T.nilable(String),
|
456
|
+
minimum: T.nilable(Integer),
|
457
|
+
maximum: T.nilable(Integer),
|
458
|
+
is: T.nilable(Integer),
|
459
|
+
within: T.nilable(T::Range[Integer]),
|
460
|
+
in: T.nilable(T::Range[Integer]),
|
461
|
+
too_long: String,
|
462
|
+
too_short: String,
|
463
|
+
wrong_length: String,
|
464
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
465
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
466
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
467
|
+
allow_nil: T::Boolean,
|
468
|
+
allow_blank: T::Boolean,
|
469
|
+
strict: T::Boolean
|
470
|
+
).void
|
471
|
+
end
|
472
|
+
def validates_size_of(
|
473
|
+
*attr_names,
|
474
|
+
message: nil,
|
475
|
+
minimum: nil,
|
476
|
+
maximum: nil,
|
477
|
+
is: nil,
|
478
|
+
within: nil,
|
479
|
+
in: nil,
|
480
|
+
too_long: 'is too long (maximum is %{count} characters)',
|
481
|
+
too_short: 'is too short (minimum is %{count} characters)',
|
482
|
+
wrong_length: 'is the wrong length (should be %{count} characters)',
|
483
|
+
if: nil,
|
484
|
+
unless: :_,
|
485
|
+
on: :_,
|
486
|
+
allow_nil: false,
|
487
|
+
allow_blank: false,
|
488
|
+
strict: false
|
489
|
+
); end
|
490
|
+
|
491
|
+
# Create a type alias so we don't have to repeat this long type signature 6 times.
|
492
|
+
NumberComparatorType = T.type_alias {T.nilable(T.any(Integer, Float, T.proc.params(arg0: T.untyped).returns(T::Boolean), Symbol))}
|
493
|
+
sig do
|
494
|
+
params(
|
495
|
+
attr_names: T.any(String, Symbol),
|
496
|
+
message: String,
|
497
|
+
only_integer: T::Boolean,
|
498
|
+
greater_than: NumberComparatorType,
|
499
|
+
greater_than_or_equal_to: NumberComparatorType,
|
500
|
+
equal_to: NumberComparatorType,
|
501
|
+
less_than: NumberComparatorType,
|
502
|
+
less_than_or_equal_to: NumberComparatorType,
|
503
|
+
other_than: NumberComparatorType,
|
504
|
+
odd: T::Boolean,
|
505
|
+
even: T::Boolean,
|
506
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
507
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
508
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
509
|
+
allow_nil: T::Boolean,
|
510
|
+
allow_blank: T::Boolean,
|
511
|
+
strict: T::Boolean
|
512
|
+
).void
|
513
|
+
end
|
514
|
+
def validates_numericality_of(
|
515
|
+
*attr_names,
|
516
|
+
message: 'is not a number',
|
517
|
+
only_integer: false,
|
518
|
+
greater_than: nil,
|
519
|
+
greater_than_or_equal_to: nil,
|
520
|
+
equal_to: nil,
|
521
|
+
less_than: nil,
|
522
|
+
less_than_or_equal_to: nil,
|
523
|
+
other_than: nil,
|
524
|
+
odd: false,
|
525
|
+
even: false,
|
526
|
+
if: nil,
|
527
|
+
unless: :_,
|
528
|
+
on: :_,
|
529
|
+
allow_nil: false,
|
530
|
+
allow_blank: false,
|
531
|
+
strict: false
|
532
|
+
); end
|
533
|
+
|
534
|
+
sig do
|
535
|
+
params(
|
536
|
+
attr_names: T.any(String, Symbol),
|
537
|
+
message: String,
|
538
|
+
if: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
539
|
+
unless: T.any(Symbol, String, T.proc.params(arg0: T.untyped).returns(T::Boolean)),
|
540
|
+
on: T.any(Symbol, String, T::Array[T.any(Symbol, String)]),
|
541
|
+
allow_nil: T::Boolean,
|
542
|
+
allow_blank: T::Boolean,
|
543
|
+
strict: T::Boolean
|
544
|
+
).void
|
545
|
+
end
|
546
|
+
def validates_presence_of(
|
547
|
+
*attr_names,
|
548
|
+
message: "can't be blank",
|
549
|
+
if: nil,
|
550
|
+
unless: :_,
|
551
|
+
on: :_,
|
552
|
+
allow_nil: false,
|
553
|
+
allow_blank: false,
|
554
|
+
strict: false
|
555
|
+
); end
|
556
|
+
end
|
557
|
+
|
558
|
+
mixes_in_class_methods(ClassMethods)
|
559
|
+
end
|
560
|
+
|
561
|
+
ActiveModel::Validations::NumericalityValidator::CHECKS = T.let(T.unsafe(nil), T::Hash[T.untyped, T.untyped])
|
562
|
+
|
563
|
+
ActiveModel::Validations::NumericalityValidator::HEXADECIMAL_REGEX = T.let(T.unsafe(nil), Regexp)
|
564
|
+
|
565
|
+
ActiveModel::Validations::NumericalityValidator::INTEGER_REGEX = T.let(T.unsafe(nil), Regexp)
|
566
|
+
|
567
|
+
ActiveModel::Validations::NumericalityValidator::RESERVED_OPTIONS = T.let(T.unsafe(nil), T::Array[T.untyped])
|
568
|
+
|
569
|
+
class ActiveModel::Errors
|
570
|
+
include Enumerable
|
571
|
+
Elem = type_member(fixed: T.untyped)
|
572
|
+
|
573
|
+
sig { params(key: T.any(String, Symbol)).returns(T::Array[String]) }
|
574
|
+
def [](key); end
|
575
|
+
|
576
|
+
def each(&blk); end
|
577
|
+
|
578
|
+
# Adds `message` to the error messages and used validator type to `details` on `attribute`.
|
579
|
+
# More than one error can be added to the same `attribute`.
|
580
|
+
# If no `message` is supplied, `:invalid` is assumed.
|
581
|
+
#
|
582
|
+
# ```ruby
|
583
|
+
# person.errors.add(:name)
|
584
|
+
# # => ["is invalid"]
|
585
|
+
# person.errors.add(:name, :not_implemented, message: "must be implemented")
|
586
|
+
# # => ["is invalid", "must be implemented"]
|
587
|
+
# ```
|
588
|
+
#
|
589
|
+
# ```ruby
|
590
|
+
# person.errors.messages
|
591
|
+
# # => {:name=>["is invalid", "must be implemented"]}
|
592
|
+
# ```
|
593
|
+
#
|
594
|
+
# ```ruby
|
595
|
+
# person.errors.details
|
596
|
+
# # => {:name=>[{error: :not_implemented}, {error: :invalid}]}
|
597
|
+
# ```
|
598
|
+
#
|
599
|
+
# If `message` is a symbol, it will be translated using the appropriate
|
600
|
+
# scope (see `generate_message`).
|
601
|
+
#
|
602
|
+
# If `message` is a proc, it will be called, allowing for things like
|
603
|
+
# `Time.now` to be used within an error.
|
604
|
+
#
|
605
|
+
# If the `:strict` option is set to `true`, it will raise
|
606
|
+
# ActiveModel::StrictValidationFailed instead of adding the error.
|
607
|
+
# `:strict` option can also be set to any other exception.
|
608
|
+
#
|
609
|
+
# ```ruby
|
610
|
+
# person.errors.add(:name, :invalid, strict: true)
|
611
|
+
# # => ActiveModel::StrictValidationFailed: Name is invalid
|
612
|
+
# person.errors.add(:name, :invalid, strict: NameIsInvalid)
|
613
|
+
# # => NameIsInvalid: Name is invalid
|
614
|
+
#
|
615
|
+
# person.errors.messages # => {}
|
616
|
+
# ```
|
617
|
+
#
|
618
|
+
# `attribute` should be set to `:base` if the error is not
|
619
|
+
# directly associated with a single attribute.
|
620
|
+
#
|
621
|
+
# ```ruby
|
622
|
+
# person.errors.add(:base, :name_or_email_blank,
|
623
|
+
# message: "either name or email must be present")
|
624
|
+
# person.errors.messages
|
625
|
+
# # => {:base=>["either name or email must be present"]}
|
626
|
+
# person.errors.details
|
627
|
+
# # => {:base=>[{error: :name_or_email_blank}]}
|
628
|
+
# ```
|
629
|
+
sig do
|
630
|
+
params(
|
631
|
+
attribute: T.any(Symbol, String),
|
632
|
+
message: T.any(String, Symbol),
|
633
|
+
options: T::Hash[T.untyped, T.untyped]
|
634
|
+
).returns(T.untyped)
|
635
|
+
end
|
636
|
+
def add(attribute, message = :invalid, options = {}); end
|
637
|
+
|
638
|
+
# Returns `true` if an error on the attribute with the given message is
|
639
|
+
# present, or `false` otherwise. `message` is treated the same as for `add`.
|
640
|
+
#
|
641
|
+
# ```ruby
|
642
|
+
# person.errors.add :name, :blank
|
643
|
+
# person.errors.added? :name, :blank # => true
|
644
|
+
# person.errors.added? :name, "can't be blank" # => true
|
645
|
+
# ```
|
646
|
+
#
|
647
|
+
# If the error message requires options, then it returns `true` with
|
648
|
+
# the correct options, or `false` with incorrect or missing options.
|
649
|
+
#
|
650
|
+
# ```ruby
|
651
|
+
# person.errors.add :name, :too_long, { count: 25 }
|
652
|
+
# person.errors.added? :name, :too_long, count: 25 # => true
|
653
|
+
# person.errors.added? :name, "is too long (maximum is 25 characters)" # => true
|
654
|
+
# person.errors.added? :name, :too_long, count: 24 # => false
|
655
|
+
# person.errors.added? :name, :too_long # => false
|
656
|
+
# person.errors.added? :name, "is too long" # => false
|
657
|
+
# ```
|
658
|
+
sig do
|
659
|
+
params(
|
660
|
+
attribute: Symbol,
|
661
|
+
message: T.any(String, Symbol),
|
662
|
+
options: T::Hash[T.untyped, T.untyped]
|
663
|
+
).returns(T::Boolean)
|
664
|
+
end
|
665
|
+
def added?(attribute, message = :invalid, options = {}); end
|
666
|
+
|
667
|
+
# Returns `true` if an error on the attribute with the given message is
|
668
|
+
# present, or `false` otherwise. `message` is treated the same as for `add`.
|
669
|
+
#
|
670
|
+
# ```ruby
|
671
|
+
# person.errors.add :age
|
672
|
+
# person.errors.add :name, :too_long, { count: 25 }
|
673
|
+
# person.errors.of_kind? :age # => true
|
674
|
+
# person.errors.of_kind? :name # => false
|
675
|
+
# person.errors.of_kind? :name, :too_long # => true
|
676
|
+
# person.errors.of_kind? :name, "is too long (maximum is 25 characters)" # => true
|
677
|
+
# person.errors.of_kind? :name, :not_too_long # => false
|
678
|
+
# person.errors.of_kind? :name, "is too long" # => false
|
679
|
+
# ```
|
680
|
+
sig do
|
681
|
+
params(
|
682
|
+
attribute: Symbol,
|
683
|
+
message: T.any(String, Symbol)
|
684
|
+
).returns(T::Boolean)
|
685
|
+
end
|
686
|
+
def of_kind?(attribute, message = :invalid); end
|
687
|
+
|
688
|
+
# Returns all the full error messages in an array.
|
689
|
+
#
|
690
|
+
# ```ruby
|
691
|
+
# class Person
|
692
|
+
# validates_presence_of :name, :address, :email
|
693
|
+
# validates_length_of :name, in: 5..30
|
694
|
+
# end
|
695
|
+
#
|
696
|
+
# person = Person.create(address: '123 First St.')
|
697
|
+
# person.errors.full_messages
|
698
|
+
# # => ["Name is too short (minimum is 5 characters)", "Name can't be blank", "Email can't be blank"]
|
699
|
+
# ```
|
700
|
+
sig { returns(T::Array[String]) }
|
701
|
+
def full_messages; end
|
702
|
+
|
703
|
+
sig { returns(T::Hash[Symbol, T::Array[String]]) }
|
704
|
+
def messages; end
|
705
|
+
|
706
|
+
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
707
|
+
def empty?(*args, &block); end
|
708
|
+
|
709
|
+
sig { params(full_messages: T::Boolean).returns(T::Hash[Symbol, T::Array[String]]) }
|
710
|
+
def to_hash(full_messages = false); end
|
711
|
+
end
|
712
|
+
|
713
|
+
ActiveModel::Errors::CALLBACKS_OPTIONS = T.let(T.unsafe(nil), T::Array[T.untyped])
|
714
|
+
|
715
|
+
ActiveModel::Errors::MESSAGE_OPTIONS = T.let(T.unsafe(nil), T::Array[T.untyped])
|