Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pridees authored Nov 8, 2021
1 parent 6837e0f commit b5261c7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,31 @@ Useful satellite for validation user inputs proposes for any SwiftUI architectur


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

```swift
class FormViewModel: ObservableObject {

@Published var email = ""
public lazy var emailValidator: ValidationPublisher = {
$email.validateWithRegex(
regex: RegularPattern.email,
error: "Not email",
tableName: nil
)
}()
}
```
Excellent! And then, call the validate view modifier from your SwiftUI Input

```swift
TextField("Should email", text: $viewModel.email)
.validate(for: viewModel.emailValidator)
```

Enjoy!

Same steps you can apply to `SecureField` and `Toggle`.

## CombineValidateExtended library
Useful set of validation publishers and regular expressions library.
Expand Down

0 comments on commit b5261c7

Please sign in to comment.