- Notifications
You must be signed in to change notification settings - Fork0
Library of standards implemented to use in ASP.NET Core
License
marcusturewicz/standards-aspnetcore
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Library of standards implemented to use in ASP.NET Core.
For example, it provides convenient abstractions for enforcingDateTime
objects are binded with ISO-8601 format (YYYY-MM-DD) in MVC.
Standards.AspNetCore currently targets .NET 6+. We follow the .NET Core support policy and therefore support only the LTS versions. When an LTS version goes out of support, we will update the major version of the library, drop support for the previous LTS version, and only target the next LTS version.
Standards.AspNetCore is available as aNuGet package.
Useful for ensuring consistent Date format contracts in RESTful APIs.IsoDateModelBinder
enforcesDateTime
model binding with ISO-8601 format (YYYY-MM-DD) in MVC. This can be used in two ways:
- In single Controller actions:
[HttpGet]publicIActionResultGet([ModelBinder(typeof(IsoDateModelBinder))]DateTimedate){returnOk("Date is in ISO format");}
- Set globally in the application via Startup:
publicoverridevoidConfigureServices(IServiceCollectionservices){services.AddControllers(options=>{options.ModelBinderProviders.Insert(0,newIsoDateModelBinderProvider());})}
Then, only dates in ISO-8601 format (YYYY-MM-DD) can be binded. For example,/api?date=2021-01-01
will be successfully binded. However,/api?date=01-01-2021
will not, and the following error message will be added to the problem details response:
"Invalid date; must be in ISO-8601 format i.e. YYYY-MM-DD."
Currently onlyIsoDateModelBinder
is implemented. The intention is for further useful international standards to be implemented in this library.
Check out thecontributing page to see the best ways to contribute.
See theCode of Conduct for the best ways to interact with this project.
Standards.AspNetCore is licensed under theMIT license.
About
Library of standards implemented to use in ASP.NET Core