Batressc.DocumentValidators.Extensions
1.0.1
dotnet add package Batressc.DocumentValidators.Extensions --version 1.0.1
NuGet\Install-Package Batressc.DocumentValidators.Extensions -Version 1.0.1
<PackageReference Include="Batressc.DocumentValidators.Extensions" Version="1.0.1" />
paket add Batressc.DocumentValidators.Extensions --version 1.0.1
#r "nuget: Batressc.DocumentValidators.Extensions, 1.0.1"
// Install Batressc.DocumentValidators.Extensions as a Cake Addin #addin nuget:?package=Batressc.DocumentValidators.Extensions&version=1.0.1 // Install Batressc.DocumentValidators.Extensions as a Cake Tool #tool nuget:?package=Batressc.DocumentValidators.Extensions&version=1.0.1
Verificación de DUI y NIT para El Salvador
Actualización crítica (22/08/2022)
Se reportó que los DUIs terminados en cero no se validaban correctamente. Se realizó la corrección correspondiente. Muchas gracias a Saúl Valdez.
Esta librería de clases contiene dos métodos de extensión para el tipo de dato System.String
que permite validar si el NIT o el DUI poseen el formato correcto y si sus dígitos son válidos, determinando el dígito validador.
A continuación se presenta código de una aplicación de consola (.NET 6) donde se verifica un DUI y NIT:
// Especificamos que vamos a utilizar los métodos de extensión
using Batressc.DocumentValidators.Extensions;
namespace ConsoleApp1 {
internal class Program {
static void Main(string[] args) {
string dui = "03096201-2";
Console.WriteLine($"Validating dui {dui}: {dui.IsValidDUI()}");
string nit = "0513-010180-238-7";
Console.WriteLine($"Validating nit {nit}: {nit.IsValidNIT()}");
}
}
}
Los métodos de extensión poseen dos enumeradores que modifican el comportanmiento de los validadores:
MiddleDashBehavior
determina si se aceptan o no los guiones medios en el DUI o NIT. Por defecto su valor esOpcional
.EvaluatorMode
determina si la cadena de entrada permitirá espacios en blanco al principio o al final. Por defecto su valor esStrict
(no permite espacios).
Para cambiar el comportamiento por defecto, solamente hay que especificar uno o ambos parámetros al llamar a los métodos de extensión:
// no se permiten guiones en la cadena de entrada. Este valor retornará False
string dui = "03096201-2";
dui.IsValidDUI(MiddleDashBehavior.NotUse);
// No se permiten guiones y se permiten espacios al principio o al final. Este valor retornará True
string nit = " 05130101802387 ";
nit.IsValidNIT(MiddleDashBehavior.NotUse, EvaluatorMode.Permissive);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.