Skip to content

A fully customizable SwiftUI form builder for building dynamic, validated forms with support for real-time validation, multiple input types, and a sleek phone number field with country picker and emoji flags.

Notifications You must be signed in to change notification settings

med-temimi/FormBuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“‹ FormBuilder - Advanced SwiftUI Form Input Handler

FormBuilder is a customizable and lightweight SwiftUI utility that simplifies complex form input handling with support for:

  • Custom validation logic
  • Real-time and deferred validation
  • Support for various input types (text, email, password, picker, date, phone)
  • Country phone code picker with flags πŸ‡ΉπŸ‡³
  • Seamless integration in SwiftUI apps

πŸš€ Features

  • βœ… Reusable form field view model
  • πŸ“¦ Built-in validation for common types (email, password, etc.)
  • 🌍 Country picker for phone input with flag emojis and dialing codes
  • πŸ”’ Supports secure inputs and required field indicators
  • 🧠 Tracks user interaction for intelligent validation feedback

🧱 Structure

  • FormFieldViewModel: Handles the state, validation, and interaction logic per field.
  • FormBuilderViewModel: Manages multiple fields, global validation state.
  • AdvancedFormField: SwiftUI component that binds directly to a FormFieldViewModel.
  • CountryPhonePickerView: UI for selecting country flags and codes.
  • CountryPhoneCodes.json: A full list of countries, ISO codes, and dialing codes.

πŸ“¦ Installation

Simply copy the FormBuilder directory into your SwiftUI project.

πŸ›  Usage

@StateObject var username = FormFieldViewModel()
username.inputType = .text
username.validation = { $0.isEmpty ? "Username required" : nil }

AdvancedFormField(viewModel: username, label: "Username", placeholder: "Your username")

For full example, see ContentView.swift.

🌐 Country Phone Code Example:

phoneField.inputType = .phone
phoneField.validation = { number in
    number.count < 8 ? "Too short" : nil
}

About

A fully customizable SwiftUI form builder for building dynamic, validated forms with support for real-time validation, multiple input types, and a sleek phone number field with country picker and emoji flags.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages