Skip to content

Commit 0a160ec

Browse files
committed
Merge branch 'hotfix/1.4.1'
2 parents 42c8533 + d360dea commit 0a160ec

File tree

6 files changed

+4
-325
lines changed

6 files changed

+4
-325
lines changed

Example/FieldValidatorSample.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
A0533DC624EAEF9E009C784B /* FieldValidator+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0533DC524EAEF9E009C784B /* FieldValidator+Helpers.swift */; };
1919
A059CE6F26DB8EA9007002F2 /* FieldValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = A059CE6E26DB8EA9007002F2 /* FieldValidator.swift */; };
2020
A059CE7126DB925E007002F2 /* FormWithValidatorV1.swift in Sources */ = {isa = PBXBuildFile; fileRef = A059CE7026DB925E007002F2 /* FormWithValidatorV1.swift */; };
21-
A059CE7326DB9272007002F2 /* FormWithValidatorV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = A059CE7226DB9272007002F2 /* FormWithValidatorV2.swift */; };
2221
/* End PBXBuildFile section */
2322

2423
/* Begin PBXFileReference section */
@@ -35,7 +34,6 @@
3534
A0533DC524EAEF9E009C784B /* FieldValidator+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FieldValidator+Helpers.swift"; sourceTree = "<group>"; };
3635
A059CE6E26DB8EA9007002F2 /* FieldValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FieldValidator.swift; path = ../Sources/FieldValidatorLibrary/FieldValidator.swift; sourceTree = "<group>"; };
3736
A059CE7026DB925E007002F2 /* FormWithValidatorV1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormWithValidatorV1.swift; sourceTree = "<group>"; };
38-
A059CE7226DB9272007002F2 /* FormWithValidatorV2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormWithValidatorV2.swift; sourceTree = "<group>"; };
3937
/* End PBXFileReference section */
4038

4139
/* Begin PBXFrameworksBuildPhase section */
@@ -80,7 +78,6 @@
8078
5F4486B523568D18007FA51F /* Info.plist */,
8179
5F4486AF23568D18007FA51F /* Preview Content */,
8280
A059CE7026DB925E007002F2 /* FormWithValidatorV1.swift */,
83-
A059CE7226DB9272007002F2 /* FormWithValidatorV2.swift */,
8481
);
8582
path = FieldValidatorSample;
8683
sourceTree = "<group>";
@@ -169,7 +166,6 @@
169166
A059CE7126DB925E007002F2 /* FormWithValidatorV1.swift in Sources */,
170167
A0533DC624EAEF9E009C784B /* FieldValidator+Helpers.swift in Sources */,
171168
A017662124F3BB5A00E04DE3 /* String+Email.swift in Sources */,
172-
A059CE7326DB9272007002F2 /* FormWithValidatorV2.swift in Sources */,
173169
A047652023DDF687005B8547 /* PasswordToggleField.swift in Sources */,
174170
5F4486AA23568D17007FA51F /* SceneDelegate.swift in Sources */,
175171
5F4486AC23568D17007FA51F /* ContentView.swift in Sources */,

Example/FieldValidatorSample/ContentView.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,10 @@ struct ContentView : View {
2323

2424
NavigationView {
2525
TabView {
26-
FormWithValidatorV2()
27-
.environmentObject( DataItem() )
28-
.tabItem {
29-
Label("Form validator v2", systemImage: "list.dash")
30-
}
31-
3226
FormWithValidatorV1()
3327
.environmentObject( DataItem() )
3428
.tabItem {
35-
Label("Form validator v1", systemImage: "square.and.pencil")
29+
Label("Form validator", systemImage: "square.and.pencil")
3630
}
3731
}
3832
.navigationBarTitle( Text( "FieldValidator Samples" ), displayMode: .inline )

Example/FieldValidatorSample/FormWithValidatorV2.swift

Lines changed: 0 additions & 155 deletions
This file was deleted.

FieldValidatorLibrary.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
1616
#
1717

1818
spec.name = "FieldValidatorLibrary"
19-
spec.version = "2.0.0"
19+
spec.version = "1.4.1"
2020
spec.summary = "SwiftUI library supporting 'Form Validation'"
2121

2222
# This description is used to generate tags and improve search results.
@@ -81,7 +81,7 @@ Pod::Spec.new do |spec|
8181
# Supports git, hg, bzr, svn and HTTP.
8282
#
8383

84-
spec.source = { :git => "https://github.com/bsorrentino/swiftui-fieldvalidator.git", :tag => "v2.0.0" }
84+
spec.source = { :git => "https://github.com/bsorrentino/swiftui-fieldvalidator.git", :tag => "v1.4.1" }
8585

8686

8787
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

README.md

Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -19,105 +19,11 @@ This Library is compatible with [Cocoapods](https://cocoapods.org).
1919

2020
In your **Podfile** add
2121
```
22-
pod 'FieldValidatorLibrary', '~> 2.0.0'
22+
pod 'FieldValidatorLibrary', '~> 1.4.1'
2323
```
2424

2525
## Sample
2626

27-
### Version 2
28-
29-
```swift
30-
31-
// validation closure where ‘v’ is the current value
32-
func usernameValididator( _ v:String ) -> String? {
33-
if( v.isEmpty ) {
34-
return "email cannot be empty"
35-
}
36-
if( !v.isEmail() ) {
37-
return "email is not in correct format"
38-
}
39-
40-
return nil
41-
}
42-
43-
// validation closure where ‘v’ is the current value
44-
func passwordValididator( _ v:String ) -> String? {
45-
if( v.isEmpty ) {
46-
return "password cannot be empty"
47-
}
48-
return nil
49-
}
50-
51-
struct FormWithValidatorV2 : View {
52-
@EnvironmentObject var item:DataItem// data model reference
53-
54-
@StateObject var username = FieldValidator2( "", debounceInMills: 700, validator: usernameValididator )
55-
@StateObject var password = FieldValidator2( "", validator: passwordValididator)
56-
57-
func usernameView() -> some View {
58-
TextField( "give me the email",
59-
text: $username.value,
60-
onCommit: submit)
61-
.autocapitalization(.none)
62-
.padding( .bottom, 25 )
63-
.overlay( ValidatorMessageInline( message: username.errorMessageOrNilAtBeginning ), alignment: .bottom)
64-
.onAppear {
65-
username.doValidate()
66-
}
67-
.onChange(of: username.value) {
68-
item.username = $0
69-
}
70-
}
71-
72-
func passwordToggleView() -> some View {
73-
SecureField( "give me the password", text: $password.value )
74-
.autocapitalization(.none)
75-
.padding( .bottom, 25 )
76-
.overlay( ValidatorMessageInline( message: password.errorMessage ),alignment: .bottom)
77-
.onAppear {
78-
password.doValidate()
79-
}
80-
.onChange(of: password.value) {
81-
item.password = $0
82-
}
83-
}
84-
85-
var isValid:Bool {
86-
password.valid && username.valid
87-
}
88-
89-
func submit() {
90-
if( isValid ) {
91-
print( "submit:\nusername:\(self.username.value)\npassword:\(self.password.value)")
92-
}
93-
}
94-
95-
var body: some View {
96-
NavigationView {
97-
Form {
98-
Section(header: Text("Credentials")) {
99-
usernameView()
100-
passwordToggleView()
101-
} // end of section
102-
Section {
103-
HStack {
104-
Spacer()
105-
Button( "Submit" ) { self.submit() }
106-
// enable button only if username and password are valid
107-
.disabled( !self.isValid )
108-
Spacer()
109-
}
110-
} // end of section
111-
} // end of form
112-
.navigationBarTitle( Text( "Sample Form" ), displayMode: .inline )
113-
} // NavigationView
114-
}
115-
}
116-
117-
```
118-
119-
### Version 1 (Deprecated)
120-
12127
```swift
12228

12329
struct FormWithValidatorV1 : View {

0 commit comments

Comments
 (0)