-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use `[AllowNull]` to skip null check * Add support for `SkipSelf` validations
- Loading branch information
1 parent
5ca282f
commit 7a17711
Showing
7 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/Immediate.Validations.FunctionalTests/IntegrationTests/SkipSelfTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Immediate.Validations.Shared; | ||
using Xunit; | ||
|
||
namespace Immediate.Validations.FunctionalTests.IntegrationTests; | ||
|
||
public sealed partial class SkipSelfTests | ||
{ | ||
[Validate] | ||
public partial record BaseClass : IValidationTarget<BaseClass> | ||
{ | ||
public required string BaseString { get; init; } | ||
} | ||
|
||
[Validate(SkipSelf = true)] | ||
public sealed partial record SubClass : BaseClass, IValidationTarget<SubClass> | ||
{ | ||
public required string IgnoredString { get; init; } | ||
} | ||
|
||
[Fact] | ||
public void SkipSelfOperatesCorrectly() | ||
{ | ||
var instance = new SubClass { BaseString = null!, IgnoredString = null!, }; | ||
|
||
var errors = SubClass.Validate(instance); | ||
|
||
Assert.Equal( | ||
[ | ||
new() | ||
{ | ||
PropertyName = nameof(BaseClass.BaseString), | ||
ErrorMessage = "'Base String' must not be null.", | ||
} | ||
], | ||
errors | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters