@@ -63,7 +63,7 @@ public static class Luhn
63
63
/// </summary>
64
64
/// <param name="number">An identification number w/o check digit.</param>
65
65
/// <returns>The calculated Luhn check digit.</returns>
66
- /// <exception cref="ArgumentException "><paramref name="number"/> is not valid.
66
+ /// <exception cref="InvalidCharacterException "><paramref name="number"/> is not valid.
67
67
/// It contains none-numeric characters.</exception>
68
68
[ SuppressMessage ( "ReSharper" , "UnusedMember.Global" ) ]
69
69
[ SuppressMessage ( "ReSharper" , "HeapView.ObjectAllocation" ) ]
@@ -76,7 +76,7 @@ public static byte ComputeLuhnCheckDigit(this ReadOnlySpan<char> number) =>
76
76
/// </summary>
77
77
/// <param name="number">An identification number w/o check digit.</param>
78
78
/// <returns>The calculated Luhn check digit as a byte.</returns>
79
- /// <exception cref="ArgumentException "><paramref name="number"/> is not valid.
79
+ /// <exception cref="InvalidCharacterException "><paramref name="number"/> is not valid.
80
80
/// It contains none-numeric characters.</exception>
81
81
[ SuppressMessage ( "ReSharper" , "UnusedMember.Global" ) ]
82
82
[ SuppressMessage ( "ReSharper" , "HeapView.ObjectAllocation" ) ]
@@ -93,7 +93,7 @@ public static byte ComputeLuhnCheckDigit(this string number) =>
93
93
/// </summary>
94
94
/// <param name="number">An identification number w/o check digit.</param>
95
95
/// <returns>The calculated Luhn number.</returns>
96
- /// <exception cref="ArgumentException "><paramref name="number"/> is not valid.
96
+ /// <exception cref="InvalidCharacterException "><paramref name="number"/> is not valid.
97
97
/// It contains none-numeric characters.</exception>
98
98
[ SuppressMessage ( "ReSharper" , "UnusedMember.Global" ) ]
99
99
[ SuppressMessage ( "ReSharper" , "HeapView.ObjectAllocation" ) ]
@@ -109,7 +109,7 @@ public static string ComputeLuhnNumber(this ReadOnlySpan<char> number)
109
109
/// </summary>
110
110
/// <param name="number">An identification number w/o check digit.</param>
111
111
/// <returns>The calculated Luhn number.</returns>
112
- /// <exception cref="ArgumentException "><paramref name="number"/> is not valid.
112
+ /// <exception cref="InvalidCharacterException "><paramref name="number"/> is not valid.
113
113
/// It contains none-numeric characters.</exception>
114
114
[ SuppressMessage ( "ReSharper" , "UnusedMember.Global" ) ]
115
115
[ SuppressMessage ( "ReSharper" , "HeapView.ObjectAllocation" ) ]
@@ -134,7 +134,7 @@ public static string ComputeLuhnNumber(this string number)
134
134
/// <param name="luhnNumber">An identification number w/ check digit (Luhn Number).</param>
135
135
/// <returns><see langword="true" /> if the <paramref name="luhnNumber"/> is valid;
136
136
/// otherwise <see langword="false" /></returns>
137
- /// <exception cref="ArgumentException "><paramref name="luhnNumber"/> is not valid.
137
+ /// <exception cref="InvalidCharacterException "><paramref name="luhnNumber"/> is not valid.
138
138
/// It contains none-numeric characters.</exception>
139
139
/// <remarks>The check digit must be at the end of the <paramref name="luhnNumber"/>
140
140
/// (on the right side).</remarks>
@@ -150,7 +150,7 @@ public static bool IsValidLuhnNumber(this ReadOnlySpan<char> luhnNumber) =>
150
150
/// <param name="luhnNumber">An identification number w/ check digit (Luhn Number).</param>
151
151
/// <returns><see langword="true" /> if the <paramref name="luhnNumber"/> is valid;
152
152
/// otherwise <see langword="false" /></returns>
153
- /// <exception cref="ArgumentException "><paramref name="luhnNumber"/> is not valid.
153
+ /// <exception cref="InvalidCharacterException "><paramref name="luhnNumber"/> is not valid.
154
154
/// It contains none-numeric characters.</exception>
155
155
/// <remarks>The check digit must be at the end of the <paramref name="luhnNumber"/>
156
156
/// (on the right side).</remarks>
@@ -171,7 +171,7 @@ public static bool IsValidLuhnNumber(this string luhnNumber) =>
171
171
/// <param name="number">Identification number w/o Luhn check digit</param>
172
172
/// <returns><see langword="true" /> if the <paramref name="number"/> is valid;
173
173
/// otherwise <see langword="false" /></returns>
174
- /// <exception cref="ArgumentException "><paramref name="number"/> is not valid.
174
+ /// <exception cref="InvalidCharacterException "><paramref name="number"/> is not valid.
175
175
/// It contains none-numeric characters.</exception>
176
176
/// <exception cref="ArgumentOutOfRangeException">The <paramref name="checkDigit"/> value is greater than 9.
177
177
/// The <paramref name="checkDigit"/> value must be between 0 and 9.</exception>
@@ -203,7 +203,7 @@ public static bool IsValidLuhnCheckDigit(this byte checkDigit, ReadOnlySpan<char
203
203
/// <param name="number">Identification number w/o Luhn check digit</param>
204
204
/// <returns><see langword="true" /> if the <paramref name="number"/> is valid;
205
205
/// otherwise <see langword="false" /></returns>
206
- /// <exception cref="ArgumentException "><paramref name="number"/> is not valid.
206
+ /// <exception cref="InvalidCharacterException "><paramref name="number"/> is not valid.
207
207
/// It contains none-numeric characters.</exception>
208
208
/// <exception cref="ArgumentOutOfRangeException">The <paramref name="checkDigit"/> value is greater than 9.
209
209
/// The <paramref name="checkDigit"/> value must be between 0 and 9.</exception>
@@ -240,7 +240,7 @@ public static bool IsValidLuhnCheckDigit(this byte checkDigit, string number)
240
240
/// <param name="alphaNumeric">The alphanumeric string to convert.</param>
241
241
/// <returns>A numeric string where each letter in the input string is replaced by its decimal ASCII value
242
242
/// minus 55.</returns>
243
- /// <exception cref="ArgumentException ">The <paramref name="alphaNumeric"/> contains a character
243
+ /// <exception cref="InvalidCharacterException ">The <paramref name="alphaNumeric"/> contains a character
244
244
/// that is neither a letter nor a digit.</exception>
245
245
/// <remarks>
246
246
/// This method iterates over each character in the input string. If the character is a letter, it is replaced
@@ -268,7 +268,7 @@ public static string AlphaNumericToNumeric(this string alphaNumeric)
268
268
}
269
269
else
270
270
{
271
- throw new ArgumentException ( $ "The character '{ c } ' is not a letter or a digit!", nameof ( alphaNumeric ) ) ;
271
+ throw new InvalidCharacterException ( $ "The character '{ c } ' is not a letter or a digit!", nameof ( alphaNumeric ) ) ;
272
272
}
273
273
}
274
274
@@ -290,7 +290,7 @@ public static string AlphaNumericToNumeric(this string alphaNumeric)
290
290
}
291
291
else
292
292
{
293
- throw new ArgumentException ( $ "The character '{ c } ' is not a letter or a digit!", nameof ( alphaNumeric ) ) ;
293
+ throw new InvalidCharacterException ( $ "The character '{ c } ' is not a letter or a digit!", nameof ( alphaNumeric ) ) ;
294
294
}
295
295
}
296
296
@@ -340,13 +340,13 @@ private static IEnumerable<uint> DoubleEverySecondDigit(this IEnumerable<uint> d
340
340
/// </summary>
341
341
/// <param name="number">An identification number</param>
342
342
/// <returns>The trimmed identification number if valid</returns>
343
- /// <exception cref="ArgumentException "><paramref name="number"/> is not a valid number</exception>
343
+ /// <exception cref="InvalidCharacterException "><paramref name="number"/> is not a valid number</exception>
344
344
private static string ValidateAndTrimNumber ( this string number )
345
345
{
346
346
string trimmedNumber = number ? . Trim ( ) ;
347
347
if ( string . IsNullOrWhiteSpace ( trimmedNumber ) || ! Regex . IsMatch ( trimmedNumber , @"^\d+$" ) )
348
348
{
349
- throw new ArgumentException ( $ "The string '{ number } ' is not a number!", nameof ( number ) ) ;
349
+ throw new InvalidCharacterException ( $ "The string '{ number } ' is not a number!", nameof ( number ) ) ;
350
350
}
351
351
352
352
return trimmedNumber ;
@@ -359,13 +359,13 @@ private static string ValidateAndTrimNumber(this string number)
359
359
/// </summary>
360
360
/// <param name="number">An identification number</param>
361
361
/// <returns>The trimmed identification number if valid</returns>
362
- /// <exception cref="ArgumentException "><paramref name="number"/> is not a valid number</exception>
362
+ /// <exception cref="InvalidCharacterException "><paramref name="number"/> is not a valid number</exception>
363
363
private static ReadOnlySpan < char > ValidateAndTrimNumber ( this ReadOnlySpan < char > number )
364
364
{
365
365
var trimmedNumber = number . Trim ( ) ;
366
366
if ( trimmedNumber . Length == 0 || ! trimmedNumber . IsDigits ( ) )
367
367
{
368
- throw new ArgumentException ( $ "The string '{ number } ' is not a number!", nameof ( number ) ) ;
368
+ throw new InvalidCharacterException ( $ "The string '{ number } ' is not a number!", nameof ( number ) ) ;
369
369
}
370
370
371
371
return trimmedNumber ;
0 commit comments