This repository was archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Custom view model validators
Alexanderius edited this page Jun 30, 2019
·
3 revisions
The model validators are working the same as binders.
To use custom model validator you should register it using HttpModelHandler.RegisterModelValidator, it will be added to validators pipeline.
public class Startup
{
public void Configuration(IAppBuilder app)
{
...
HttpModelHandler.RegisterModelValidator<MyModelValidator>();
app.UseSimplifyWeb();
}
}Validator should be deriver from IModelValidator interface.
public class MyModelValidator : IModelValidator
{
public void Validate<T>(T model)
{
// Validation logic
}
}If you just want to use your validator without default validators, then you should clear validators list first.
public class Startup
{
public void Configuration(IAppBuilder app)
{
...
HttpModelHandler.ModelValidatorsTypes.Clear();
HttpModelHandler.RegisterModelValidator<MyModelValidator>();
app.UseSimplifyWeb();
}
}- Getting Started
- Main Simplify.Web principles
- Simplify.Web controllers
- Simplify.Web views
- Simplify.Web templates
- Simplify.Web configuration
- Templates variables
- Static content
- Template factory
- Data collector
- String table
- File reader
- Web context
- Environment
- Language manager
- Redirector
- HTML