Verificoder 1.0.0.2

dotnet add package Verificoder --version 1.0.0.2                
NuGet\Install-Package Verificoder -Version 1.0.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Verificoder" Version="1.0.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Verificoder --version 1.0.0.2                
#r "nuget: Verificoder, 1.0.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Verificoder as a Cake Addin
#addin nuget:?package=Verificoder&version=1.0.0.2

// Install Verificoder as a Cake Tool
#tool nuget:?package=Verificoder&version=1.0.0.2                

Verificoder

Generate your customized Verification Code on .Net Core.

In some cases, you need to create random numbers between 4 and 8 digits, so this package helps you to have a general code generator for all parts of your program in the .NET modular structure.

Authors

Features (Configuration)

  • Code Length
  • Max of digit repeatation
  • Global and Inline Configuration
  • DI (IVerificoder)
  • Caching the code by phone and validation it

Install

Install with Package Manager Console

  Install-Package Verificoder

Add/DI

// default configuration
services.AddVerificoder();
// if you want use customize setting
services.AddVerificoder(options => {
      options.StartWithZero = true; // default is false 
      options.DefaultLength = 5; // default is 5
      options.DefualtMaxRepeatNumber = 2; // default is 1,
      // if you want use scoped code
      options.ScopeCodeAbsoluteExpiration = TimeSpan.FromMinutes(2); // default is TimeSpan.FromMinutes(1) 
});

Usage/Simple mode

private readonly IVerificoder _verificoder;

public AccountController(IVerificoder verificoder)
{
    _verificoder = verificoder;
}

public IActionResult SendVerifyCode(string phone)
{
    var verifyCode = _verificoder.TakeOne();

    var result _smsService.SendSms(phone, $"your account verification code is :{verifyCode}");

    return Ok();
}

Usage/Scoped Mode

private readonly IVerificoder _verificoder;

public AccountController(IVerificoder verificoder)
{
    _verificoder = verificoder;
}

public IActionResult SendVerifyCode(string phone)
{
       // if last code not expired, you can't take new code.
       // you can set Expiration time when adding option to DI, [ScopeCodeAbsoluteExpiration]
       if (_verificoder.CanTakeOnScope(phone))
       {
           var verifyCode = _verificoder.TakeOnScope(phone);
                 
           var message = string
               .Format("your account verification code is :{0}", verifyCode);

           _smsService.SendSms(phone, message);

           return Ok("Code was Sent to the Phone number.");
       }
 
       return BadRequest("You can't ");
}


public IActionResult CreateAccount(string phone,string userValidationCode)
{

        if(!_verificoder.IsValidOnScope(phone,userValidationCode))
        {
            return BadRequest("Please enter valid codes.");
        }

       // other creation account code
}

Inline/Configuration

// length 7 and default max repeat(1)
var verifyCode = _verificoder.TakeOne(7);
// scoped mode
var verifyCode = _verificoder.TakeOnScope(phone,7);



// length 7 and max repeat(3)
var verifyCode = _verificoder.TakeOne(7,3);
// scoped mode
var verifyCode = _verificoder.TakeOnScope(phone,7,3);
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0.2 459 7/1/2022
1.0.0.1 422 6/26/2022
1.0.0 414 6/25/2022