FormView

0.1.0

maxial/FormView

What's New

0.1.0

2023-02-20T20:32:21Z

The first version of the library

FormView


An easy-to-use library for working with a group of TextFields.

Features

  • Automatic transition between TextFields upon submission
  • Validation of TextFields based on specified rules
  • Prevention of incorrect input based on specified rules

Usage

struct ContentView: View {
    
    @State var email: String = ""
    @State var phone: String = ""
    
    @State var emailFailedRules: [TextValidationRule] = []
    
    var body: some View {
        FormView {
            FormField(
                "Email",
                text: $email,
                validationRules: [.email],
                failedValidationRules: $emailFailedRules
            )
            if emailFailedRules.isEmpty == false {
                Text("Email")
                    .foregroundColor(.red)
            }
            FormField(
                "Phone",
                text: $phone,
                validationRules: [.digitsOnly],
                inputRules: [.digitsOnly]
            )
        }
    }
}

ValidationRules are used for automatic validation of text during input. All rules that have not passed the validation come with the failedValidationRules.

InputRules are used to prevent incorrect input.

Example Project

ExampleApp provides several more interesting use cases of FormView.

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code.

In Xcode 14 or later, select File > Add Packages... In the search bar, type

https://github.com/maxial/FormView

Then proceed with installation.

You can add FormView as a dependency to the dependencies value of your Package.swift:

dependencies: [
    .package(url: "https://github.com/maxial/FormView", from: "main"),
]

License

FormView is released under the MIT license. See LICENSE for details.

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

Last updated: Fri Oct 18 2024 20:42:59 GMT-0900 (Hawaii-Aleutian Daylight Time)