Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sulmar/sulmar.aspnetcore.routing.routeconstraints
Route constraints for validation of Polish NIP, PESEL, REGON for .NET 5
https://github.com/sulmar/sulmar.aspnetcore.routing.routeconstraints
netcore5
Last synced: 1 day ago
JSON representation
Route constraints for validation of Polish NIP, PESEL, REGON for .NET 5
- Host: GitHub
- URL: https://github.com/sulmar/sulmar.aspnetcore.routing.routeconstraints
- Owner: sulmar
- Created: 2021-09-06T16:05:59.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-06T16:26:32.000Z (over 3 years ago)
- Last Synced: 2024-12-16T15:10:32.054Z (18 days ago)
- Topics: netcore5
- Language: C#
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sulmar.AspNetCore.Routing.RouteConstraints
Route constraints for validation of Polish NIP, PESEL, REGON for .NET 5## Get Started
RouteConstraints can be installed using the Nuget package manager or the dotnet CLI.~~~
Install-Package Sulmar.AspNetCore.Routing.RouteConstraints
~~~~~~
dotnet add package Sulmar.AspNetCore.Routing.RouteConstraints
~~~## Usage
### Register
- PESEL
~~~ csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddPeselConstraint();
}
~~~- REGON
~~~ csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddRegonConstraint();
}
~~~- NIP
~~~ csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddNipConstraint();
}
~~~- or all together
~~~ csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddPolishConstraints();
}
~~~### Add Route Constraint
- PESEL
~~~ csharp
// GET api/customers/{number}
[HttpGet("{number:pesel}")]
public ActionResult GetByPesel(string number)
{
var customer = customerService.GetByPesel(number);if (customer == null)
return NotFound();return Ok(customer);
}
~~~- REGON
~~~ csharp
// GET api/customers/{number}
[HttpGet("{number:regon}")]
public ActionResult GetByRegon(string number)
{
var customer = customerService.GetByRegon(number);if (customer == null)
return NotFound();return Ok(customer);
}
~~~- NIP
~~~ csharp
// GET api/customers/{number}
[HttpGet("{number:nip}")]
public ActionResult GetByNip(string number)
{
var customer = customerService.GetByNip(number);if (customer == null)
return NotFound();return Ok(customer);
}
~~~