Skip to content

Commit 6ba0543

Browse files
horghclaude
andcommitted
Add YARD documentation for undocumented modules and methods
This brings the YARD documentation coverage from 92.19% to 100%. Modules documented: - Minfraud::Components: Container for request component classes - Minfraud::Components::Report: Components for the Report Transaction API - Minfraud::HTTPService: HTTP communication handling classes - Minfraud::Model: Response model classes for Score/Insights/Factors Methods documented: - Minfraud::Enum.included: Hook called when Enum module is included - Minfraud::Validates: All 16 validation helper methods now have documentation describing their purpose, parameters, and exceptions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3862c57 commit 6ba0543

6 files changed

Lines changed: 151 additions & 0 deletions

File tree

lib/minfraud/components/base.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# frozen_string_literal: true
22

33
module Minfraud
4+
# Components are used to build the request to the minFraud services.
5+
# Each component represents a part of the transaction being analyzed,
6+
# such as the device, account, email, or billing address.
47
module Components
58
# This is a parent class for all components. It defines a method which is
69
# used for basic JSON representation of the component objects.

lib/minfraud/components/report/transaction.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Minfraud
44
module Components
5+
# Components for the Report Transaction API.
56
module Report
67
# Contains the fields used in the Report Transaction API.
78
#

lib/minfraud/enum.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
module Minfraud
44
# Enum provides helpers for working with attributes with enumerated types.
55
module Enum
6+
# Hook method called when the module is included into a class.
7+
# Extends the class with ClassMethods.
8+
#
9+
# @param base [Class] The class including this module.
10+
#
11+
# @return [nil]
612
def self.included(base)
713
base.extend(ClassMethods)
814
end

lib/minfraud/http_service/response.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
require 'minfraud/model/score'
88

99
module Minfraud
10+
# HTTPService contains classes for handling HTTP communication with the
11+
# minFraud web services.
1012
module HTTPService
1113
# Response class for HTTP requests.
1214
class Response

lib/minfraud/model/abstract.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# frozen_string_literal: true
22

33
module Minfraud
4+
# Model contains classes for the minFraud response data. These classes
5+
# represent the data returned by the Score, Insights, and Factors
6+
# endpoints.
47
module Model
58
# @!visibility private
69
class Abstract

lib/minfraud/validates.rb

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@
77
# rubocop:disable Metrics/ModuleLength
88
module Minfraud
99
# @!visibility private
10+
# Validates provides validation helper methods for component input values.
11+
# These methods are used internally when validation is enabled via
12+
# Minfraud.enable_validation.
1013
module Validates
14+
# Validates that a string value does not exceed a maximum length.
15+
#
16+
# @param field [String] The field name for error messages.
17+
# @param length [Integer] The maximum allowed length.
18+
# @param value [String, nil] The value to validate.
19+
#
20+
# @raise [InvalidInputError] If the value exceeds the maximum length.
21+
#
22+
# @return [nil]
1123
def validate_string(field, length, value)
1224
return if !value
1325

@@ -16,6 +28,14 @@ def validate_string(field, length, value)
1628
end
1729
end
1830

31+
# Validates that a value is a valid MD5 hash string.
32+
#
33+
# @param field [String] The field name for error messages.
34+
# @param value [String, nil] The value to validate.
35+
#
36+
# @raise [InvalidInputError] If the value is not a valid MD5 hash.
37+
#
38+
# @return [nil]
1939
def validate_md5(field, value)
2040
return if !value
2141

@@ -24,6 +44,14 @@ def validate_md5(field, value)
2444
end
2545
end
2646

47+
# Validates that a value is a valid UUID string.
48+
#
49+
# @param field [String] The field name for error messages.
50+
# @param value [String, nil] The value to validate.
51+
#
52+
# @raise [InvalidInputError] If the value is not a valid UUID.
53+
#
54+
# @return [nil]
2755
def validate_uuid(field, value)
2856
return if !value
2957

@@ -37,6 +65,14 @@ def validate_uuid(field, value)
3765
end
3866
end
3967

68+
# Validates that a value is a valid ISO 3166-2 subdivision code.
69+
#
70+
# @param field [String] The field name for error messages.
71+
# @param value [String, nil] The value to validate.
72+
#
73+
# @raise [InvalidInputError] If the value is not a valid subdivision code.
74+
#
75+
# @return [nil]
4076
def validate_subdivision_code(field, value)
4177
return if !value
4278

@@ -45,6 +81,14 @@ def validate_subdivision_code(field, value)
4581
end
4682
end
4783

84+
# Validates that a value is a valid ISO 3166-1 alpha-2 country code.
85+
#
86+
# @param field [String] The field name for error messages.
87+
# @param value [String, nil] The value to validate.
88+
#
89+
# @raise [InvalidInputError] If the value is not a valid country code.
90+
#
91+
# @return [nil]
4892
def validate_country_code(field, value)
4993
return if !value
5094

@@ -53,6 +97,15 @@ def validate_country_code(field, value)
5397
end
5498
end
5599

100+
# Validates that a value is a valid telephone country code (1-4 digits).
101+
#
102+
# @param field [String] The field name for error messages.
103+
# @param value [String, nil] The value to validate.
104+
#
105+
# @raise [InvalidInputError] If the value is not a valid telephone country
106+
# code.
107+
#
108+
# @return [nil]
56109
def validate_telephone_country_code(field, value)
57110
return if !value
58111

@@ -61,6 +114,15 @@ def validate_telephone_country_code(field, value)
61114
end
62115
end
63116

117+
# Validates that a value matches a regular expression pattern.
118+
#
119+
# @param field [String] The field name for error messages.
120+
# @param regex [Regexp] The regular expression pattern to match.
121+
# @param value [String, nil] The value to validate.
122+
#
123+
# @raise [InvalidInputError] If the value does not match the pattern.
124+
#
125+
# @return [nil]
64126
def validate_regex(field, regex, value)
65127
return if !value
66128

@@ -69,6 +131,14 @@ def validate_regex(field, regex, value)
69131
end
70132
end
71133

134+
# Validates that a value is a valid credit card token.
135+
#
136+
# @param field [String] The field name for error messages.
137+
# @param value [String, nil] The value to validate.
138+
#
139+
# @raise [InvalidInputError] If the value is not a valid credit card token.
140+
#
141+
# @return [nil]
72142
def validate_credit_card_token(field, value)
73143
return if !value
74144

@@ -83,6 +153,14 @@ def validate_credit_card_token(field, value)
83153
end
84154
end
85155

156+
# Validates a custom input value (boolean, numeric, or string).
157+
#
158+
# @param field [String] The field name for error messages.
159+
# @param value [Boolean, Numeric, String, nil] The value to validate.
160+
#
161+
# @raise [InvalidInputError] If the value is not valid.
162+
#
163+
# @return [nil]
86164
def validate_custom_input_value(field, value)
87165
return if !value
88166

@@ -101,6 +179,14 @@ def validate_custom_input_value(field, value)
101179
validate_string(field, 255, value)
102180
end
103181

182+
# Validates that a value is a valid IPv4 or IPv6 address.
183+
#
184+
# @param field [String] The field name for error messages.
185+
# @param value [String, nil] The value to validate.
186+
#
187+
# @raise [InvalidInputError] If the value is not a valid IP address.
188+
#
189+
# @return [nil]
104190
def validate_ip(field, value)
105191
return if !value
106192

@@ -120,6 +206,15 @@ def validate_ip(field, value)
120206
nil
121207
end
122208

209+
# Validates that a value is a non-negative number within range.
210+
#
211+
# @param field [String] The field name for error messages.
212+
# @param value [Numeric, nil] The value to validate.
213+
#
214+
# @raise [InvalidInputError] If the value is not a valid non-negative
215+
# number.
216+
#
217+
# @return [nil]
123218
def validate_nonnegative_number(field, value)
124219
return if !value
125220

@@ -132,6 +227,15 @@ def validate_nonnegative_number(field, value)
132227
end
133228
end
134229

230+
# Validates that a value is a non-negative integer within range.
231+
#
232+
# @param field [String] The field name for error messages.
233+
# @param value [Integer, nil] The value to validate.
234+
#
235+
# @raise [InvalidInputError] If the value is not a valid non-negative
236+
# integer.
237+
#
238+
# @return [nil]
135239
def validate_nonnegative_integer(field, value)
136240
return if !value
137241

@@ -144,6 +248,14 @@ def validate_nonnegative_integer(field, value)
144248
end
145249
end
146250

251+
# Validates that a value is a valid email address or MD5 hash of one.
252+
#
253+
# @param field [String] The field name for error messages.
254+
# @param value [String, nil] The value to validate.
255+
#
256+
# @raise [InvalidInputError] If the value is not a valid email or MD5 hash.
257+
#
258+
# @return [nil]
147259
def validate_email(field, value)
148260
return if !value
149261

@@ -155,6 +267,14 @@ def validate_email(field, value)
155267
validate_md5(field, value)
156268
end
157269

270+
# Validates that a value is in RFC 3339 date-time format.
271+
#
272+
# @param field [String] The field name for error messages.
273+
# @param value [String, nil] The value to validate.
274+
#
275+
# @raise [InvalidInputError] If the value is not in RFC 3339 format.
276+
#
277+
# @return [nil]
158278
def validate_rfc3339(field, value)
159279
return if !value
160280

@@ -169,6 +289,14 @@ def validate_rfc3339(field, value)
169289
nil
170290
end
171291

292+
# Validates that a value is a boolean.
293+
#
294+
# @param field [String] The field name for error messages.
295+
# @param value [Boolean, nil] The value to validate.
296+
#
297+
# @raise [InvalidInputError] If the value is not a boolean.
298+
#
299+
# @return [nil]
172300
def validate_boolean(field, value)
173301
return if !value
174302

@@ -177,6 +305,14 @@ def validate_boolean(field, value)
177305
end
178306
end
179307

308+
# Validates that a value is a valid absolute URI.
309+
#
310+
# @param field [String] The field name for error messages.
311+
# @param value [String, nil] The value to validate.
312+
#
313+
# @raise [InvalidInputError] If the value is not a valid absolute URI.
314+
#
315+
# @return [nil]
180316
def validate_uri(field, value)
181317
return if !value
182318

0 commit comments

Comments
 (0)