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