Closed arielmoraes closed 5 years ago
Para contornar o problema enquanto não é liberado uma nova versão do pacote nuget eu criei um ContractExtension conforme abaixo:
public static class ContractExtensions
{
/// <summary>
/// This method is a workaround beacuse exists a problem in oginal method HasMinLen from Flunt package in version 1.0.2
/// see more in https://github.com/andrebaltieri/flunt/issues/19
/// </summary>
/// <returns></returns>
public static Contract HasMinLength(this Contract contract, string val, int min, string property, string message)
{
if (string.IsNullOrEmpty(val) || val.Length < min)
{
contract.AddNotification(property, message);
}
return contract;
}
/// <summary>
/// This method is a workaround beacuse exists a problem in oginal method HasMinLen from Flunt package in version 1.0.2
/// see more in https://github.com/andrebaltieri/flunt/issues/19
/// </summary>
/// <returns></returns>
public static Contract HasMaxLength(this Contract contract, string val, int max, string property, string message)
{
if (string.IsNullOrEmpty(val) || val.Length > max)
{
contract.AddNotification(property, message);
}
return contract;
}
}
É a solução que tomamos por enquanto também, enviei uma mensagem pro Baltieri, talvez ele tenha deixado de dar manutenção.
@andrebaltieri poderia me colocar como colaborador nesse repo?
Gerando nova versão hoje! Sorry guys!
A versão atual do NuGet, apesar de ser a mesma do projeto - 1.0.2, está com um problema nos métodos
HasMinLen
eHasMaxLen
. Ambos estão sem a verificaçãostring.IsNullOrEmpty
no pacote NuGet.