You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,11 +57,13 @@ struct MyField: View {
57
57
```swift
58
58
structContentView: View {
59
59
@Statevar name: String=""
60
+
@Statevar isAllFieldValid =false
60
61
61
62
var body: some View {
62
63
FormView( First failed field
63
64
validate: .never, // Form will be validated on user action.
64
-
hideError: .onValueChanged// Error for field wil be hidden on field value change.
65
+
hideError: .onValueChanged, // Error for field wil be hidden on field value change.
66
+
isAllFieldValid: $isAllFieldValid // Property indicating the result of validation of all fields without focus
65
67
) { proxy in
66
68
FormField(
67
69
value: $name,
@@ -74,6 +76,7 @@ struct ContentView: View {
74
76
// Validate form on user action.
75
77
print("Form is valid: \(proxy.validate())")
76
78
}
79
+
.disabled(isAllFieldValid ==false) // Use isAllFieldValid to automatically disable the action button
77
80
}
78
81
}
79
82
}
@@ -92,6 +95,9 @@ Error for each field gets hidden at one of three specific times:
92
95
*`onFocus` - field with error is focused..
93
96
*`onFucusLost` - field with error lost focus.
94
97
98
+
### Is All Field Valid
99
+
Property indicating the result of validation of all fields without focus. Using this property you can additionally build ui update logic, for example block the next button.
100
+
95
101
### Custom Validation Rules
96
102
One of two ways:
97
103
1. Adopt protocol `ValidationRule`:
@@ -224,7 +230,7 @@ FormView doesn't use any external dependencies.
0 commit comments