title: Does anyone know how can I validate digits from my currency input?
body: <p>My validation rules :
  only accepts 5 numbers, only accepts 2 decimals
  I have this so far but the problem is that stil accepts more than 2 decimals for example:
  $ 99,999.00123445 (not Ok)
  $ 99,999.99 (Ok)
  I set numbers left to right for example: $0.01, $0.19, $1.99
  What is wrong?</p>
  
  <pre><code>@IBAction func efectivoTextChanged(_ sender: UITextField) {
      guard let text = sender.text else{
          return
      }
      let array = text.compactMap({
          Int(String($0))
      })
      let num = Double(array.reduce(0, {($0 * 10) + $1})) / 100
      if num &gt; 99999.99 {
          return
      }
      let num2 = num * 100 / 100
      efectivoTextField.text = currencyFormatter.string(from: NSNumber(value:  num2))
      let updatedText = efectivoTextField.text!
      updateEfect(updatedText)
  }
  </code></pre>