From b5261c78c15d6891cf435845bf310725cbf13ae7 Mon Sep 17 00:00:00 2001 From: Alexo Date: Mon, 8 Nov 2021 13:56:23 +0300 Subject: [PATCH] Update README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index b181b83..d75fb79 100644 --- a/README.md +++ b/README.md @@ -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.