Skip to content

Commit b5261c7

Browse files
authored
Update README.md
1 parent 6837e0f commit b5261c7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,31 @@ Useful satellite for validation user inputs proposes for any SwiftUI architectur
3333

3434

3535
## Basic usage
36+
Firstly you should define the validation publisher within your `@Published` property
3637

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`.
3761

3862
## CombineValidateExtended library
3963
Useful set of validation publishers and regular expressions library.

0 commit comments

Comments
 (0)