Skip to content

Commit 1651106

Browse files
authored
refactor!: change results to record types (#311)
1 parent b56d4ac commit 1651106

18 files changed

+87
-90
lines changed

src/IbanNet/Validation/Results/CountryNotAcceptedResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace IbanNet.Validation.Results;
77
/// <summary>
88
/// The result returned when the IBAN passed validation, but is explicitly rejected because it failed to pass a <see cref="AcceptCountryRule" /> or <see cref="RejectCountryRule" /> rule which was added to the validation pipeline.
99
/// </summary>
10-
public class CountryNotAcceptedResult : ErrorResult
10+
public record CountryNotAcceptedResult : ErrorResult
1111
{
1212
/// <summary>
1313
/// The result returned when the IBAN is not accepted because of restrictions by country.

src/IbanNet/Validation/Results/CountryResolvedResult.cs

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

33
namespace IbanNet.Validation.Results;
44

5-
internal sealed class CountryResolvedResult(IbanCountry country) : ValidationRuleResult
6-
{
7-
public IbanCountry Country { get; } = country;
8-
}
5+
internal record CountryResolvedResult(IbanCountry Country) : ValidationRuleResult;

src/IbanNet/Validation/Results/ErrorResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// Describes the error that occurred for a validation rule. Custom validation errors should derive from this class.
55
/// </summary>
6-
public class ErrorResult : ValidationRuleResult
6+
public record ErrorResult : ValidationRuleResult
77
{
88
/// <summary>
99
/// Initializes a new instance of the <see cref="ErrorResult" /> class using specified <paramref name="errorMessage" />.
@@ -18,4 +18,4 @@ public ErrorResult(string errorMessage)
1818
/// Gets the error message.
1919
/// </summary>
2020
public string ErrorMessage { get; }
21-
}
21+
}

src/IbanNet/Validation/Results/ExceptionResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// Describes the error that occurred for a validation rule.
55
/// </summary>
6-
public class ExceptionResult : ErrorResult
6+
public record ExceptionResult : ErrorResult
77
{
88
/// <summary>
99
/// Initializes a new instance of the <see cref="ExceptionResult" /> class using specified <paramref name="exception" />.
@@ -19,4 +19,4 @@ public ExceptionResult(Exception exception)
1919
/// Gets the exception.
2020
/// </summary>
2121
public Exception Exception { get; }
22-
}
22+
}

src/IbanNet/Validation/Results/IllegalCharactersResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// The result returned when the IBAN contains illegal characters.
55
/// </summary>
6-
public class IllegalCharactersResult : ErrorResult
6+
public record IllegalCharactersResult : ErrorResult
77
{
88
/// <summary>
99
/// Initializes a new instance of the <see cref="IllegalCharactersResult" /> class.
@@ -34,4 +34,4 @@ protected IllegalCharactersResult(string errorMessage, int position)
3434
/// Gets the character position where the first illegal character was encountered.
3535
/// </summary>
3636
public int Position { get; }
37-
}
37+
}

src/IbanNet/Validation/Results/IllegalCountryCodeCharactersResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// The result returned when the IBAN contains illegal characters in the country code.
55
/// </summary>
6-
public class IllegalCountryCodeCharactersResult
6+
public record IllegalCountryCodeCharactersResult
77
: IllegalCharactersResult
88
{
99
/// <summary>
@@ -14,4 +14,4 @@ public IllegalCountryCodeCharactersResult(int position)
1414
: base(Resources.IllegalCountryCodeCharactersResult, position)
1515
{
1616
}
17-
}
17+
}

src/IbanNet/Validation/Results/InvalidCheckDigitsResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// The result returned when the IBAN check digits are incorrect.
55
/// </summary>
6-
public class InvalidCheckDigitsResult : ErrorResult
6+
public record InvalidCheckDigitsResult : ErrorResult
77
{
88
/// <summary>
99
/// Initializes a new instance of the <see cref="InvalidCheckDigitsResult" /> class.
@@ -12,4 +12,4 @@ public InvalidCheckDigitsResult()
1212
: base(Resources.InvalidCheckDigitsResult)
1313
{
1414
}
15-
}
15+
}

src/IbanNet/Validation/Results/InvalidLengthResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// The result returned when the IBAN has an incorrect length.
55
/// </summary>
6-
public class InvalidLengthResult : ErrorResult
6+
public record InvalidLengthResult : ErrorResult
77
{
88
/// <summary>
99
/// Initializes a new instance of the <see cref="InvalidLengthResult" /> class.
@@ -12,4 +12,4 @@ public InvalidLengthResult()
1212
: base(Resources.InvalidLengthResult)
1313
{
1414
}
15-
}
15+
}

src/IbanNet/Validation/Results/InvalidQrIbanResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// The result returned when the IBAN is not a valid QR IBAN.
55
/// </summary>
6-
public class InvalidQrIbanResult : ErrorResult
6+
public record InvalidQrIbanResult : ErrorResult
77
{
88
/// <summary>
99
/// Initializes a new instance of the <see cref="InvalidQrIbanResult" /> class.

src/IbanNet/Validation/Results/InvalidStructureResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// The result returned when the structure of the IBAN is incorrect.
55
/// </summary>
6-
public class InvalidStructureResult : ErrorResult
6+
public record InvalidStructureResult : ErrorResult
77
{
88
/// <summary>
99
/// Initializes a new instance of the <see cref="InvalidStructureResult" /> class.
@@ -19,4 +19,4 @@ public InvalidStructureResult(int position)
1919
/// Gets the character position where the first illegal character was encountered.
2020
/// </summary>
2121
public int Position { get; }
22-
}
22+
}

0 commit comments

Comments
 (0)