Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

FormValidatorKit

FormValidatorKit is a reusable Swift Package that provides a complete, scalable, and production-ready form validation framework for Apple platforms using SwiftUI.

It supports:

  • Built-in validation support for TextField, SecureField, etc.
  • Validation states: Idle, Focused, Valid, Invalid, Warning, Loading, Disabled
  • Validation messages: Error, Success, Warning, Helper
  • Built-in validators (Required, Email, Password, MinLength, etc.)
  • Custom validation engine for async/API-based validation
  • Reusable UI validation components (ValidatedTextField, ValidatedSecureField)
  • Theming system for full UI customization
  • Centralized FormState management

Requirements

  • iOS 15+
  • macOS 12+
  • Swift 6.2+

Installation

Swift Package Manager

In Xcode:

  1. Go to File > Add Packages...
  2. Enter your repository URL for FormValidatorKit
  3. Select the version/range and add the package

Or in Package.swift:

dependencies: [
    .package(url: "https://github.com/Coderkube-App/FormValidatorKit.git", from: "1.0.0")
],
targets: [
    .target(
        name: "YourApp",
        dependencies: [
            .product(name: "FormValidatorKit", package: "FormValidatorKit")
        ]
    )
]

Package Structure

FormValidatorKit/
 ├── Sources/FormValidatorKit/
 │   ├── Core/
 │   ├── Data/
 │   ├── Domain/
 │   └── Presentation/
 ├── Tests/FormValidatorKitTests/
 └── Package.swift

Usage

Single Field Validation

import SwiftUI
import FormValidatorKit

struct LoginView: View {
    @State private var email = ""
    
    var body: some View {
        ValidatedTextField(
            title: "Email",
            text: $email,
            validators: [.required(), .email()]
        )
    }
}

Form State Management

struct SignupView: View {
    @StateObject var form = FormState()
    @State private var email = ""
    @State private var password = ""
    
    var body: some View {
        Form {
            ValidatedTextField(
                title: "Email",
                text: $email,
                validators: [.required(), .email()],
                formState: form,
                fieldId: "email"
            )
            
            ValidatedSecureField(
                title: "Password",
                text: $password,
                validators: [.required(), .minLength(8)],
                formState: form,
                fieldId: "password"
            )
            
            Button("Submit") {
                if form.validateAll() {
                    print("Form is valid")
                }
            }
            .disabled(!form.isValid)
        }
    }
}

Testing

Run tests:

swift test

Automated Versioning

This repository uses a GitHub Actions workflow to automatically create version tags and GitHub Releases after changes are merged into main.

Version bump rules:

  • fix: or other non-breaking commits -> patch bump (x.y.Z)
  • feat: -> minor bump (x.Y.0)
  • BREAKING CHANGE in the commit body or footer -> major bump (X.0.0)

Design Notes

  • Clean Architecture principles applied
  • Reusable UI components
  • Centralized form state validation

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages