Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/filipe11402/futils-validations
.NET Util to validate brand specific credit card numbers
https://github.com/filipe11402/futils-validations
Last synced: 4 days ago
JSON representation
.NET Util to validate brand specific credit card numbers
- Host: GitHub
- URL: https://github.com/filipe11402/futils-validations
- Owner: filipe11402
- Created: 2022-02-03T22:16:09.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-05-21T14:57:41.000Z (over 2 years ago)
- Last Synced: 2023-03-09T05:41:14.242Z (almost 2 years ago)
- Language: C#
- Homepage: https://www.nuget.org/packages/FUtils.CreditCard.Validations/
- Size: 19.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Credit Card number validation library
Validate your credit card numbers based on their brand using data anotations
---
# How to use### .NET CLI
```
dotnet add package FUtils.CreditCard.Validations
```### Nuget
```
Install-Package FUtils.CreditCard.Validations
```---
## Validate MasterCard credit card
```cs
public class CreditCardModel
{
//choose the desired credit card brand
//in this case MasterCard
[MasterCard]
public string CreditCardNumber { get; set; }
}
``````cs
public class CreditCardController : Controller
{
//Use your model as the model that get's the data
[HttpPost]
[Route("/")]
public IActionResult MyRoute([FromBody] CreditCardModel myModel)
{
//This will check if the credit card number is valid
//You can then return an error message to your taste
if(ModelState.IsValid)
{
return StatusCode(StatusCodes.400BadRequest);
}
//Apply your logic
//...
return StatusCode(StatusCodes.200OK);
}
}
```