DamianEdwards / DamianEdwards/MiniValidation
Support valdation attributes on types
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 390
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
I've built a nested Data Annotations validator myself. It turns out that yours is faster (in most cases), so I'm considering dropping my own validator in favor of this one. However, I noticed that you do not support ValidationAttributes on types. Was that a deliberate choice, or is some ware on your to-do list?
[Fact]
public void Invalid_When_Model_Is_Invalid_By_TypeAttribute()
{
var sot = new TestClass();
var result = MiniValidator.TryValidate(sot, out var errors);
Assert.False(result);
Assert.Single(errors);
Assert.Equal(string.Empty, errors.Keys.First());
}
[InvalidType]
class TestClass { }
[AttributeUsage(AttributeTargets.Class)]
class InvalidTypeAttribute : ValidationAttribute
{
public override bool IsValid(object? value) => false;
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at MiniValidator.TryValidate and the existing DataAnnotations validation path, using the supplied InvalidType test as the expected behavior. Done means a ValidationAttribute applied to a class is evaluated and produces the shown single error with an empty key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100