Validate Contact Fields in Real Time During Editing
The Edit Contact Screen applies field-level validation as part of Flutter's reactive form validation system. Validation is triggered on field blur (when the user leaves a field) and on step-advance attempts. Validation rules include required field checks, format validation (phone numbers, email addresses), maximum length constraints, and type-specific rules for custom fields (e.g., date fields must be valid dates, select fields must match a defined option). Error messages appear inline below the offending field using a consistent error style from the design token system. The Contact Management Service applies a second layer of server-side validation on submission to guard against any client-side bypass. All validation messages are in Norwegian (or the organisation's configured language) and are announced to screen readers.
User Story
Acceptance Criteria
- Given a user enters a value in a required field and then clears it, when the field loses focus, then an inline 'Required' error message appears below the field
- Given a user enters a malformed phone number, when the field loses focus, then an inline format error is displayed with an example of the expected format
- Given a user attempts to advance to the next step with validation errors present, when they tap the next button, then advancement is blocked and all errors on the current step are highlighted
- Given all fields on a step are valid, when the user advances, then no error messages are shown and the next step loads
- Given a user corrects a previously invalid field, when the field value becomes valid, then the error message disappears immediately without requiring blur
- Given a screen reader is active, when a validation error appears, then the error message is announced to the user immediately
Business Value
Real-time field validation prevents invalid data from entering the contact database, which directly protects the integrity of Bufdir reports that draw on contact and activity data. For peer mentors with lower digital literacy or cognitive accessibility needs, immediate feedback on errors is far less frustrating and less cognitively demanding than discovering all errors at submission time. This also reduces coordinator correction overhead by ensuring data quality at the point of entry.
Components
- Edit Contact Screen ui
- Contact Management Service service