moving validator to parent
This commit is contained in:
parent
868836b963
commit
fb7760a329
@ -49,6 +49,9 @@ import UIKit
|
|||||||
|
|
||||||
public var isValid: Bool = false
|
public var isValid: Bool = false
|
||||||
|
|
||||||
|
/// Validate on each entry in the textField. Default: true
|
||||||
|
public var validateEachCharacter: Bool = true
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Computed Properties
|
// MARK: - Computed Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -229,6 +232,32 @@ import UIKit
|
|||||||
entryFieldContainer.updateView(size)
|
entryFieldContainer.updateView(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Validation
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
/// Executes on .textDidBeginEditingNotification
|
||||||
|
@objc func startEditing() {
|
||||||
|
isSelected = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Executes on .textDidChangeNotification (each character entry)
|
||||||
|
@objc func valueChanged() {
|
||||||
|
guard validateEachCharacter else { return }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Executes on .textDidEndEditingNotification
|
||||||
|
@objc func endInputing() {
|
||||||
|
isSelected = false
|
||||||
|
resignFirstResponder()
|
||||||
|
|
||||||
|
// Don't show error till user starts typing.
|
||||||
|
guard text?.count ?? 0 != 0 else {
|
||||||
|
showError = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MoleculeViewProtocol
|
// MARK: - MoleculeViewProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -51,9 +51,6 @@ import UIKit
|
|||||||
|
|
||||||
private var observingForChange: Bool = false
|
private var observingForChange: Bool = false
|
||||||
|
|
||||||
/// Validate on each entry in the textField. Default: true
|
|
||||||
public var validateEachCharacter: Bool = true
|
|
||||||
|
|
||||||
/// Validate when user resigns editing. Default: true
|
/// Validate when user resigns editing. Default: true
|
||||||
public var validateWhenDoneEditing: Bool = true
|
public var validateWhenDoneEditing: Bool = true
|
||||||
|
|
||||||
@ -261,27 +258,20 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Executes on UITextField.textDidBeginEditingNotification
|
/// Executes on UITextField.textDidBeginEditingNotification
|
||||||
@objc func startEditing() {
|
@objc override func startEditing() {
|
||||||
isSelected = true
|
super.startEditing()
|
||||||
textField.becomeFirstResponder()
|
textField.becomeFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes on UITextField.textDidChangeNotification (each character entry)
|
/// Executes on UITextField.textDidChangeNotification (each character entry)
|
||||||
@objc func valueChanged() {
|
@objc override func valueChanged() {
|
||||||
guard validateEachCharacter else { return }
|
super.valueChanged()
|
||||||
isSelected = true
|
|
||||||
validateTextField()
|
validateTextField()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes on UITextField.textDidEndEditingNotification
|
/// Executes on UITextField.textDidEndEditingNotification
|
||||||
@objc func endInputing() {
|
@objc override func endInputing() {
|
||||||
resignFirstResponder()
|
super.endInputing()
|
||||||
|
|
||||||
// Don't show error till user starts typing.
|
|
||||||
guard text?.count ?? 0 != 0 else {
|
|
||||||
showError = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if let isValid = textEntryFieldModel?.isValid {
|
if let isValid = textEntryFieldModel?.isValid {
|
||||||
self.isValid = isValid
|
self.isValid = isValid
|
||||||
|
|||||||
@ -24,9 +24,6 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Validate on each entry in the textView. Default: true
|
|
||||||
public var validateEachCharacter: Bool = true
|
|
||||||
|
|
||||||
private var observingForChange: Bool = false
|
private var observingForChange: Bool = false
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -194,27 +191,20 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Executes on UITextView.textDidBeginEditingNotification
|
/// Executes on UITextView.textDidBeginEditingNotification
|
||||||
@objc func startEditing() {
|
@objc override func startEditing() {
|
||||||
isSelected = true
|
super.startEditing()
|
||||||
_ = textView.becomeFirstResponder()
|
_ = textView.becomeFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes on UITextView.textDidChangeNotification (each character entry)
|
/// Executes on UITextView.textDidChangeNotification (each character entry)
|
||||||
@objc func valueChanged() {
|
@objc override func valueChanged() {
|
||||||
guard validateEachCharacter else { return }
|
super.valueChanged()
|
||||||
validateTextView()
|
validateTextView()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes on UITextView.textDidEndEditingNotification
|
/// Executes on UITextView.textDidEndEditingNotification
|
||||||
@objc func endInputing() {
|
@objc override func endInputing() {
|
||||||
isSelected = false
|
super.endInputing()
|
||||||
resignFirstResponder()
|
|
||||||
|
|
||||||
// Don't show error till user starts typing.
|
|
||||||
guard text?.count ?? 0 != 0 else {
|
|
||||||
showError = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if let isValid = textViewEntryFieldModel?.isValid {
|
if let isValid = textViewEntryFieldModel?.isValid {
|
||||||
self.isValid = isValid
|
self.isValid = isValid
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user