File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,31 @@ Useful satellite for validation user inputs proposes for any SwiftUI architectur
33
33
34
34
35
35
## Basic usage
36
+ Firstly you should define the validation publisher within your ` @Published ` property
36
37
38
+ ``` swift
39
+ class FormViewModel : ObservableObject {
40
+
41
+ @Published var email = " "
42
+ public lazy var emailValidator: ValidationPublisher = {
43
+ $email.validateWithRegex (
44
+ regex : RegularPattern.email ,
45
+ error : " Not email" ,
46
+ tableName : nil
47
+ )
48
+ }()
49
+ }
50
+ ```
51
+ Excellent! And then, call the validate view modifier from your SwiftUI Input
52
+
53
+ ``` swift
54
+ TextField (" Should email" , text : $viewModel.email )
55
+ .validate (for : viewModel.emailValidator )
56
+ ```
57
+
58
+ Enjoy!
59
+
60
+ Same steps you can apply to ` SecureField ` and ` Toggle ` .
37
61
38
62
## CombineValidateExtended library
39
63
Useful set of validation publishers and regular expressions library.
You can’t perform that action at this time.
0 commit comments