Skip to content

Commit 43fbc45

Browse files
committed
Implement an extension for ValidationModifier
1 parent 596ae17 commit 43fbc45

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// Validator
3+
// Copyright © 2023 Space Code. All rights reserved.
4+
//
5+
6+
import SwiftUI
7+
import ValidatorCore
8+
9+
public extension View {
10+
func validate<T, ErrorView: View>(
11+
item: Binding<T>,
12+
rules: [any IValidationRule<T>],
13+
@ViewBuilder content: @escaping ([any IValidationError]) -> ErrorView
14+
) -> some View {
15+
modifier(
16+
ValidationViewModifier(
17+
item: item,
18+
rules: rules,
19+
content: content
20+
)
21+
)
22+
}
23+
}

0 commit comments

Comments
 (0)