Skip to content

Commit 78bd07a

Browse files
Remove Type Constraints (#18)
* Remove type constraint on `IValidationTarget * Remove type constraint on relational Validators
1 parent 8b6d333 commit 78bd07a

File tree

5 files changed

+5
-9
lines changed

5 files changed

+5
-9
lines changed

src/Immediate.Validations.Shared/IValidationTarget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Immediate.Validations.Shared;
88
/// <typeparam name="T">
99
/// The type which should be validated.
1010
/// </typeparam>
11-
public interface IValidationTarget<T> where T : IValidationTarget<T>
11+
public interface IValidationTarget<T>
1212
{
1313
/// <summary>
1414
/// A method which can be used to validate instances of the type <typeparamref name="T"/>.

src/Immediate.Validations.Shared/Validators/GreaterThanAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ object operand
2929
/// A <see cref="ValueTuple{T1, T2}"/> indicating whether the property is valid or not, along with an error
3030
/// message if the property is not valid.
3131
/// </returns>
32-
public static (bool Invalid, string? Message) ValidateProperty<T>(T target, T operand)
33-
where T : IComparable<T> =>
32+
public static (bool Invalid, string? Message) ValidateProperty<T>(T target, T operand) =>
3433
Comparer<T>.Default.Compare(target, operand) > 0
3534
? default
3635
: (true, $"Value '{target}' is not greater than '{operand}'");

src/Immediate.Validations.Shared/Validators/GreaterThanOrEqualAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ object operand
2929
/// A <see cref="ValueTuple{T1, T2}"/> indicating whether the property is valid or not, along with an error
3030
/// message if the property is not valid.
3131
/// </returns>
32-
public static (bool Invalid, string? Message) ValidateProperty<T>(T target, T operand)
33-
where T : IComparable<T> =>
32+
public static (bool Invalid, string? Message) ValidateProperty<T>(T target, T operand) =>
3433
Comparer<T>.Default.Compare(target, operand) >= 0
3534
? default
3635
: (true, $"Value '{target}' is not greater than or equal to '{operand}'");

src/Immediate.Validations.Shared/Validators/LessThanAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ object operand
2929
/// A <see cref="ValueTuple{T1, T2}"/> indicating whether the property is valid or not, along with an error
3030
/// message if the property is not valid.
3131
/// </returns>
32-
public static (bool Invalid, string? Message) ValidateProperty<T>(T target, T operand)
33-
where T : IComparable<T> =>
32+
public static (bool Invalid, string? Message) ValidateProperty<T>(T target, T operand) =>
3433
Comparer<T>.Default.Compare(target, operand) < 0
3534
? default
3635
: (true, $"Value '{target}' is not less than '{operand}'");

src/Immediate.Validations.Shared/Validators/LessThanOrEqualAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ object operand
2929
/// A <see cref="ValueTuple{T1, T2}"/> indicating whether the property is valid or not, along with an error
3030
/// message if the property is not valid.
3131
/// </returns>
32-
public static (bool Invalid, string? Message) ValidateProperty<T>(T target, T operand)
33-
where T : IComparable<T> =>
32+
public static (bool Invalid, string? Message) ValidateProperty<T>(T target, T operand) =>
3433
Comparer<T>.Default.Compare(target, operand) <= 0
3534
? default
3635
: (true, $"Value '{target}' is not less than or equal to '{operand}'");

0 commit comments

Comments
 (0)