Example #1
0
        /// <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;
        }
Example #2
0
 /// <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));
 }
Example #3
0
 /// <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));
 }