Comments (5)
Yes, that kind of middleware would be great! I will be happy to help.
from valit.
@paw3lx great! We'll need to find out how to implement that :D
from valit.
As far as I understand we need to create our custom ModelValidatorProvider
which can be later added using:
services.AddMvc(options => options.ModelValidatorProviders.Add(...));
I found internal implementation for the data annotations on GitHub:
This won't be a simple task, but we should nailed this anyway :D
from valit.
All right, after short break I finally got back to the project and I started doing this task localy. Surprisingly, I got first, working prototype done fairly quickly (about 30 minutes), so it's not that hard as I thought. However there are two issues that we need to overcome somehow:
-
As far as I see #113 issue is required for this task since the whole validation is based on error messages. The rule is simple: any string message == model invalid. If there's no message returned then the model is valid. I checked that with Data Annotation and it uses default messages if it's not passed to the attribute. This basically means that we simply need default messages in Valit as well.
-
One of the field returned in the validation result provided by ASP.NET Core is
memberName
which is then put intoModelState
so the user knows which property is invalid. Currently we don't have this kind of the information in theIValitResult
. This could be only guessed by messages but it's very unreliable solution since user could override it with the message not containing the name of the field. We need to come up with something more clever and ideally avoid another breaking change. But I'm afraid that it won't be that simple.
from valit.
Since the Valit.Examples repo was empty I put there my prototype with example integration. Of course it works just for specific type but at least we'll know the direction of this integration :D
from valit.
Related Issues (20)
- Asserts in tests HOT 1
- Broken develop HOT 7
- Features for v1.0.0 HOT 18
- Add more things for customising error messages HOT 2
- Validating nested objects - passing the IValitator<TObject> HOT 4
- Integrating with Autofac HOT 3
- Refactor resolving IValitResult from rules collection
- Remove IValitRulesProvider
- Resolve rules chain inside Validate
- Support for .NetStandard HOT 4
- Return custom result type from IValitResult<T> and IValitator<T> HOT 1
- Validation for reference types seems nonfunctional HOT 1
- Dont call .Satisfies() condition when .When() returns false HOT 1
- String MaxLength rule should accept empty string HOT 3
- Remove Microsoft.DotNet.Watcher.Tools from test project
- Question - Dependent Rules HOT 3
- Migrate to .NET Standard 2.1
- Migrate to .NET Core 3.1
- For(@object) throws exception when null
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from valit.