PrimerCardFormState. Read validation state from the PrimerCardFormSession inside your custom slots to display targeted error 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 with @ObservedObject (or @StateObject) and read session.state.
isValid reflects the form’s overall validity and updates as the user edits fields. Use it 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
Use the helpers onsession.state to show an inline error for a specific field. The example below renders a CVV field that highlights its border and shows a message when validation fails.
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.