PrimerCardFormState. A field shows an error when the shopper leaves it with an invalid value. The CVV field also validates as soon as it reaches its full length. The error clears when the shopper focuses that field again. Empty fields never show an error message.
Values you write with the session’s update* methods never produce a FieldError. They count toward isValid only while the matching SDK field view is on screen. Read validation state from the PrimerCardFormSession inside your custom slots to display targeted messages and gate submission.
FieldError
AFieldError represents a validation error for a single form field. It is Equatable and Identifiable (its id is the fieldType), so it works directly with SwiftUI’s ForEach.
Validation surfaces on PrimerCardFormState
Validation is exposed through the form state held byPrimerCardFormSession. Observe the session your slot receives with @ObservedObject and read session.state.
isValid is true while the SDK’s card number, expiry date, CVV and cardholder name fields all hold valid values. Billing address fields don’t count toward it. While isValid is true, the SDK keeps fieldErrors empty. It clears every entry whenever a field’s validity updates, billing errors included. Use isValid to drive the enabled state of your submit button, and use fieldErrors / errorMessage(for:) to render per-field messages.Reading a field error inside a slot
Validation runs inside the SDK’s own field views (theCardFormDefaults building blocks), which also show the field’s error message. The update* methods on PrimerCardFormSession store a value but never produce a validation error. A TextField of your own never produces a FieldError. Keep the SDK field and use the helpers on session.state to add your own UI around it. The example below adds a hint under the CVV field while it has an error.
fieldErrors directly — FieldError is Identifiable, so it slots into ForEach.
Gating submission with isValid
Bind your submit button’s enabled state tosession.state.isValid so it activates only once the form passes validation.
PrimerInputElementType
PrimerInputElementType identifies the type of input field referenced by a FieldError (and used throughout the card form). Each case has a stringValue returning the canonical string identifier.
See also
Card form session
The observable session that exposes form state, mutation methods, and submission.
Card field components
Built-in field views you can compose inside the card form slots.