Skip to content

Instantly share code, notes, and snippets.

//
// UIView+Extension.swift
//
// Created by Bruno Scheltzke on 04/06/20.
// Copyright © 2020 Bruno Scheltzke All rights reserved.
//
import UIKit
/// Tag used to remove lock view when requested
//
// UIColor+Extension.swift
//
// Created by Bruno Scheltzke on 04/06/20.
// Copyright © 2020 Bruno Scheltzke All rights reserved.
//
import UIKit
extension UIColor {
//
// String.swift
//
// Created by Bruno Scheltzke on 04/06/20.
// Copyright © 2020 Bruno Scheltzke All rights reserved.
//
import UIKit
extension String {
//
// UIScrollView.swift
//
// Created by Bruno Scheltzke on 07/06/20.
// Copyright © 2020 Bruno Scheltzke. All rights reserved.
//
import UIKit
extension UIScrollView {
//
// UITextField.swift
//
// Created by Bruno Scheltzke on 07/06/20.
// Copyright © 2020 Bruno Scheltzke. All rights reserved.
//
import UIKit
extension UITextField {
extension StringProtocol {
var isValidCNPJ: Bool {
let numbers = compactMap(\.wholeNumberValue)
guard numbers.count == 14 && Set(numbers).count != 1 else { return false }
return numbers.prefix(12).digitoCNPJ == numbers[12] &&
numbers.prefix(13).digitoCNPJ == numbers[13]
}