/// <summary> /// Initializes a new instance of the <see cref="Cnpj"/> class. /// </summary> /// <param name="value">a valid CNPJ string</param> /// <param name="punctuation">the punctuation setting to /// how validation must be handled</param> public Cnpj(string value, CnpjPunctuation punctuation) { if (StringHelper.IsNullOrWhiteSpace(value)) { throw new ArgumentException("O CNPJ não pode ser nulo ou branco"); } if (!CnpjHelper.Validate(value, punctuation)) { throw new ArgumentException("O CNPJ não é válido"); } this.parsedValue = CnpjHelper.Sanitize(value); this.Punctuation = punctuation; }
/// <summary> /// Checks if a string value is a valid CNPJ representation /// </summary> /// <param name="value">a CNPJ string to be checked</param> /// <param name="punctuation">the punctuation setting to /// how validation must be handled</param> /// <returns>true if CNPJ string is valid; otherwise, false</returns> public static bool Validate(string value, CnpjPunctuation punctuation) { return(CnpjHelper.Validate(value, punctuation)); }
/// <summary> /// Checks if a string value is a valid CNPJ representation /// </summary> /// <param name="value">a CNPJ string to be checked</param> /// <returns>true if CNPJ string is valid; false otherwise</returns> public static bool Validate(string value) { return(CnpjHelper.Validate(value, CnpjPunctuation.Loose)); }