andrebaltieri / Flunt

Validations and Notifications
https://github.com/andrebaltieri/flunt
MIT License
624 stars 162 forks source link

Pacote NuGet desatualizado #19

Closed arielmoraes closed 5 years ago

arielmoraes commented 6 years ago

A versão atual do NuGet, apesar de ser a mesma do projeto - 1.0.2, está com um problema nos métodos HasMinLene HasMaxLen. Ambos estão sem a verificação string.IsNullOrEmpty no pacote NuGet.

fernandoseguim commented 6 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;
    }
}
arielmoraes commented 6 years ago

É a solução que tomamos por enquanto também, enviei uma mensagem pro Baltieri, talvez ele tenha deixado de dar manutenção.

arielmoraes commented 5 years ago

@andrebaltieri poderia me colocar como colaborador nesse repo?

andrebaltieri commented 5 years ago

Gerando nova versão hoje! Sorry guys!