Skip to content

This allows validating values entered into Textfield and displaying any invalid entries as errors. It allows the user to submit details only after correct values are entered into Fields.

Notifications You must be signed in to change notification settings

gillgursimran/Form-Validation-with-SwiftUI-and-Combine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

image

This provides a reasonably flexible and useful SwiftUI wrapper around UITextField that provides more control over errors and invalid text.

Features

It provides the ability to:

Use of SwiftUI bindings to capture entered text and control the text field's first responder status. Observe and react to the text field's input. Set the text field's placeholder. Support for enabling and disabling the text field using the SwiftUI .setDisabled view modifier. Control over how and when text changes should be permitted. Control over if the text field should begin or end editing. Display text input errors and text field name.

Installation

Just Drag OurTextField.Swift file from source code into any project you need to use.

Usage is Easy

struct ExampleView: View { @State var email: String = "" @State var isValidEmail: Bool = false @State var emailError: String = ""

var body: some View { VStack { OurTextField( placeholder: Strings.placeholderEmail, text: $email, isValid: $isValidEmail, error: $emailError, emptyMessage: Strings.requiredField, keyboardType: .asciiCapable, textFieldType: .square ) } } }

Please refer to source code for more information about declared fields.

About

This allows validating values entered into Textfield and displaying any invalid entries as errors. It allows the user to submit details only after correct values are entered into Fields.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages