VGSExpDateTextField
@MainActor
public final class VGSExpDateTextField : VGSTextField
extension VGSExpDateTextField: UIPickerViewDelegate, UIPickerViewDataSource
An object that displays an editable text area. Can be use instead of a VGSTextField when need to show picker view with Card Number Expiration Month and Year.
Overview:
VGSExpDateTextField presents a month/year picker or keyboard for collecting card expiration date securely. It auto-validates against current month to prevent past dates and adapts its formatting based on configuration.
Features:
- Month & year picker with customizable label formats (
MonthFormat,YearFormat). - Prevents selection of expired month (auto-corrects if user navigates to past entry in current year).
- Supports keyboard input fallback when configuration sets
inputSource = .keyboard. - Integrates with
VGSExpDateConfigurationfor formatting & serialization, including tokenization scenarios.
Usage:
- Create text field and assign a
VGSExpDateConfiguration(or tokenization configuration) toconfigurationbefore editing begins. - Optionally set
monthPickerFormat/yearPickerFormatfor UI preferences. - Read
statefor validation errors; submit throughVGSCollect.
Accessibility:
- Picker components inherit system traits; provide a meaningful placeholder so VoiceOver announces context.
- Avoid exposing actual card number or other PII in any associated labels.
Performance:
- Data source arrays are lightweight; picker updates only on relevant component changes.
-
UIPickerView Month Label format
Declaration
Swift
@MainActor public var monthPickerFormat: MonthFormat { get set } -
UIPickerView Year Label format
Declaration
Swift
@MainActor public var yearPickerFormat: YearFormat { get set }
View on GitHub