Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/refactoringcpf #5

Merged
merged 13 commits into from
Dec 19, 2024
Next Next commit
CPFView refactored
diggosilva committed Dec 17, 2024
commit 31cb94a31788f28528454c6a679e8b6637aea367
Original file line number Diff line number Diff line change
@@ -18,10 +18,12 @@ public enum CPFStatus {
/// The `CPFValidator` class is responsible for validating, generating, and formatting CPF numbers (Brazilian Individual Taxpayer Registry).
///
/// It provides methods to validate a CPF, generate fake CPFs, format a CPF into a readable format, and apply a mask to the CPF.
public class CPFValidator {
public class CPFManager {
let string: String

/// Inicializa um novo validador de CPF.
public init() {}
public init(string: String) {
self.string = string

/// Validates a provided CPF, checking its format and verifying if the check digits are correct.
/// - Parameter cpf: The CPF to be validated.
6 changes: 3 additions & 3 deletions Example/App/Scenes/CPFView.swift
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ class CPFView: UIView {
return btn
}()

var cpfResult = ""
var result = ""
weak var delegate: CPFViewDelegate?

override init(frame: CGRect) {
@@ -86,9 +86,9 @@ class CPFView: UIView {

@objc private func cpfTextFieldMask() {
let cpf = textField.text ?? ""
let maskCPF = CPFValidator.init().applyMask(cpf: cpf)
let maskCPF = CPFManager.mask(cpf: cpf)
textField.text = maskCPF
cpfResult = maskCPF
result = maskCPF
}

@objc private func validateCPF() {